I have adopted a Rails app that has a lot of complex relationships. We started getting ActiveRecord::RecordNotFound error and am trying to track it down. Is there a way to wrap
relationships in a begin ... rescue block to determing which one is causing us problems similar to what they are doing here for a find method. Or is there a way to log that exact sql call that is getting the RecordNotFound error?
thx
hmm... so not able to find post I was referencing but I really just need to find the relationship that is busted. In my logs, I just see that it is rendering the template for 'not_found' records but I'm not sure what is causing it.
thx
Without your relationships & logs, everything is conjecture; but if you're getting a RecordNotFound
error - it basically means you're trying to load a record which doesn't exist in your db
Is there a way to wrap relationships in a begin ... rescue block to determing which one is causing us problems similar to what they are doing here for a find method
No - a better way to debug is to find the logs in your /log/development.log
file & then display the response here.
A pointer is that I don't think the relationship will be the issue. The relationship will just return null if nothing is there; the RecordNotFound
error will be a result of ActiveRecord
not being able to find the requested resource
EG
@post = Post.find 13 #-> RecordNotFound if a post with id 13 does not exist
If you post your logs & code, it will be the best way to help us solve your issue!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.