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

**URL:** <https://www.ruby-forum.com/t/nil-i-dont-know-no-nil-or-maybe-i-do-know-nil/109552>\
**Category:** Rails\
**Created:** [July 16, 2007, 7:50pm UTC](https://www.ruby-forum.com/t/nil-i-dont-know-no-nil-or-maybe-i-do-know-nil/109552 "2007-07-16T19:50:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kedron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@Kedron](https://www.ruby-forum.com/u/Kedron)\
**Post date:** [July 16, 2007, 7:50pm UTC](https://www.ruby-forum.com/t/nil-i-dont-know-no-nil-or-maybe-i-do-know-nil/109552/1 "2007-07-16T19:50:48Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Kedron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@Kedron](https://www.ruby-forum.com/u/Kedron)\
**Post date:** [July 16, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/nil-i-dont-know-no-nil-or-maybe-i-do-know-nil/109552/2 "2007-07-16T20:12:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Kedron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@Kedron](https://www.ruby-forum.com/u/Kedron)\
**Post date:** [July 16, 2007, 9:41pm UTC](https://www.ruby-forum.com/t/nil-i-dont-know-no-nil-or-maybe-i-do-know-nil/109552/3 "2007-07-16T21:41:02Z")

</div>

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

–

- Books:  
RAILS ROUTING (new! [http://www.awprofessional.com/title/0321509242](http://www.awprofessional.com/title/0321509242))  
RUBY FOR RAILS ([Ruby for Rails](http://www.manning.com/black))
- Ruby/Rails training  
& consulting: Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))
