Ok, I am a complete Rails Newbie but maybe this might be helpful to someone else:
Check that the column for the foreign key is named correctly in the related table!
I got stuck on this resulting in a NoMethodError for quite some time in my first rails app, when trying to get options for a select field filled with values from a related table until I realized that I did not follow the convention in the database.
I’m having the same problem. thanks for the advise.
Same here, when I tried Erik Hatcher’s enhanced authorize() method in my login controller for the online store the Rails book has us create (p. 138). I get the error after I log in to the Admin console of the site.
I’m getting the same problem and I created database schemas using ActiveRecord::Migration and ‘rake db:migrate’. I’ve been jacking around with this for 3 hours and still no luck.
I’ve been getting furstrated with Rails; when you hose something you end up looking around for hours for a fix. I suppose I should get SVN… but then I’d be hosing SVN every 5 minutes trying to figure that out.
For those who are struggling with the nomethoderror on the rails example book (can’t speak for a general nomethoderror), the problem is a simple one (after figuring out). Make sure that the methods declared (def) are not under the private section of the user class. The problem w/the book is that since it doesn’t list the whole file at a time, I just appended it at the end, resulting in the NoMethodError (I’m a newbie as well, and I’m trying to understand the issue). There is a hint on the next line after the error saying “Private method xxx called on.” (the private is kinda hard to see.
Hope this helps.
One more thing to look at is the name of the action you are trying to create. I created an action called clone. Apparently you can’t call an action “clone”. I’m guessing that somewhere in action pack there is a clone function that is getting mixed in, so your clone function never gets called. I renamed the clone method to clone_it and the NoMethodError just went away. Lame!
This advice helped me:
If you put a custom function in application.rb or another controller and then try to access it from your view, you’ll get the “No Method Error” similar to following:
NoMethodError in Categories#list
Showing app/views/categories/list.rhtml where line #23 raised:
undefined method `create_permalink’ for #<#:0xb7931838>
The solution is to place the function as a helper function in the app/helpers/categories_helper.rb or app/helpers/application_helper.rb file.