On Jan 26, 2011, at 5:48 PM, David G. wrote:
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>
If this is a copy and paste from your result, then look at the block
-- you have user_comments (plural) in there, but you refer to
user_comment inside the block.
Walter
(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!
--
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-
[email protected].
To unsubscribe from this group, send email to [email protected]
.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.