Forum: Ruby on Rails nil? I don't know no nil... or maybe I do know nil...

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
00cdec40191969152bfda41e586fe78d?d=identicon&s=25 Kedron (Guest)
on 2007-07-16 19:50
(Received via mailing list)
I was on a roll until I started customizing the look of what Rails
created for me... I broke something.

###########  NoMethodError ###########

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each


I've got a member page where I list the current member on the left
with an "Add Member" section in the main body area. When I click "Add
Member" I get the above message that references the code below.

  <% for member in @members %>
    <%= link_to member.first_name + " " + member.last_name , { # link_to
      :controller => 'members',
      :action => 'edit',
      :id => member
    } %>
  <% end %>

Thank you all for your help! I'm such a NOOB!
00cdec40191969152bfda41e586fe78d?d=identicon&s=25 Kedron (Guest)
on 2007-07-16 20:12
(Received via mailing list)
It would appear that I'm going about it the wrong way. I think I need
to split the actions up into more than one page... any thoughts?
1fba4539b6cafe2e60a2916fa184fc2f?d=identicon&s=25 unknown (Guest)
on 2007-07-16 21:41
(Received via mailing list)
Hi --

On Mon, 16 Jul 2007, Kedron wrote:

>> You have a nil object when you didn't expect it!
>>         <% for member in @members %>
'for' is a wrapper around 'each', so the problem is that @members is
nil.  I suspect that it's something like this: when you add a member,
you trigger an action that re-renders the page, after creating the new
member, but does not set @members.  That would account for the


* Books:
* Ruby/Rails training
     & consulting:  Ruby Power and Light, LLC (
This topic is locked and can not be replied to.