You are here: Forums Ask a Rails expert ActiveRecord::RecordNotFound i...
Posted in Forums : Ask a Rails expert
Authority 0
Posting Rating 0
Sign in to rate this post
|
I’m building my first ROR application and having a problem with new controller. I’ve created the Reviews controller with associated views and established a belongs_to relationship with another controller. I’m getting the above error when trying to load the page. Any ideas what I’m doing wrong? Code included below. movie.rb
end review.rb routes.rb |
Authority 50
Posting Rating 99
Sign in to rate this post
|
You get an ActiveRecord::RecordNotFound exception when you try to find a row in the database that doesn’t exist. At some point you’re executing a #find call of some kind, with, presumably, an invalid ID. It’s possible that the problem is relatively simple and you simply need to check the IDs that your controllers receive before trying to find them. It’s also possible that some of your ActiveRecord objects are trying to load associated objects which don’t exist; either because you have invalid data loaded from fixtures, or because something deleted a row leaving a dangling reference, or something else entirely. To be honest, the easiest and best way to track down problems like this is to make sure you comprehensively test your controllers as you’re writing them. Also, on an unrelated note, your example code will be easier to read in these posts if you wrap it in <pre> tags. Like so: <pre> class Movie < ActiveRecord::Base ... end ... </pre> |
Authority 0
Posting Rating 0
Sign in to rate this post
|
I do have the feeling that the answer is probably something very simple. I’m still trying to get my arms around how to properly write and perform and interpret the results of tests, and I suppose now is the best time to learn. :-) Going to check and make sure that I have the proper rows in db’s as well. And thanks for the tip on properly formatting my example code. Cracking open my simply rails 2 book again :-) Thanks for the help |
Ask a Rails expert : nested application ApplicationController get called intead of children::ApplicationController
Ask a Rails expert : Best way to structure a database for a large/static dataset
Ask a Rails expert : Ruby Developer (ROR) - Scottish based (Remote working from within the UK)
Ask a Rails expert : Above Ground Pool Supplies
Ask a Rails expert : How to get url params in observer or model in Rails 3.1
Ask a Rails expert : What can persuade you to hire Junior Ruby devs with significant PHP experience?
Ask a Rails expert : What industry value does the Ruby or Rails Certification currently have?
Ask a Rails expert : Louis Vuitton Damier Azur Canvas specially sale ( www.salecheaplouisvuitton.com )
Ask a Rails expert : ·How to check errors/puts statements from ruby files which are under cronob
Ask a Rails expert : Louis Vuitton cheap Soft Sided Luggagespecial offer( www.salecheaplouisvuitton.com )