Nil? I don't know no nil... or maybe I do know nil

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 options :controller => 'members', :action => 'edit', :id => member } %>
  • <% end %>

Thank you all for your help! I’m such a NOOB!

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?

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
nilness.

David