David G. wrote in post #977740: > I am new to Ruby on Rails and have a very simple foreign key example > that is driving me nuts. I am using Rails 3 under Windows Vista and have > two tables: users and user_comments. user_comments.user_id should > point to the user a comment is about. > > In my show view for user I have a link to the new method of > user_comments to allow a comment to be created. This throws: > > Showing c:/Gpsappm/app/views/user_comments/_form.html.erb where line #1 > raised: > > undefined method `model_name' for NilClass:Class > Extracted source (around line #1): > > 1: <%= form_for(@user_comment) do |user_comments| %> > 2: <% if @user_comment.errors.any? %> > 3: <div id="errorExplanation"> > 4: <h2><%= pluralize(@user_comment.errors.count, "error") %> > prohibited this user comment from being saved:</h2> > > (1) What exactly does this error message mean? From other posts I > gather this is a null instance of UserComments, but this is to create a > new instance? > > (2) What are the step-by-step methods I should follow to debug such > issues? > > Thanks!
Post your whole _form.html.erb file. I suspect the error is elsewhere, and Rails is pointing to line 1 because that's where the enclosing block starts. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.