# Update action | NoMethodError | nil.to\_sym

**URL:** <https://www.ruby-forum.com/t/update-action-nomethoderror-nil-to-sym/151792>\
**Category:** Rails\
**Created:** [October 25, 2008, 8:33pm UTC](https://www.ruby-forum.com/t/update-action-nomethoderror-nil-to-sym/151792 "2008-10-25T20:33:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [October 25, 2008, 8:33pm UTC](https://www.ruby-forum.com/t/update-action-nomethoderror-nil-to-sym/151792/1 "2008-10-25T20:33:26Z")

</div>

Ok, totally no reason why I’m getting an error in this model update  
and no other. HELP!

CONTROLLER:

# GET /employees/1/edit

def edit  
@employee = Employees.find(params[:id])

end

VIEW:

# Edit Employee

\<%= error\_messages\_for :employees %\>

\<% form\_for(@employee) do |f| %\>

ROUTES:

map.resources :employees

All pretty standard stuff - what’s going on?

ERROR:

NoMethodError in Employees#edit

Showing employees/edit.html.erb where line #5 raised:

You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.to\_sym

Extracted source (around line #5):

2:

  
3: \<%= error\_messages\_for :employees %\>  
4:  
5: \<% form\_for(@employee) do |f| %\>  
6: 

| Email: | \<%= f.text\_field :email %\> (required, will be login to intranet) |

  
7:   
8: 

| Email:

Thanks so much in advance!

 |

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [October 25, 2008, 9:44pm UTC](https://www.ruby-forum.com/t/update-action-nomethoderror-nil-to-sym/151792/2 "2008-10-25T21:44:21Z")

</div>

Look in your controller where you assign @employee. You are calling find  
on a  
plural model (Employees.find). Is your model defined as “Employees”? The  
Rails convention is to have models named in a singular form, ie  
Employee,  
because it defines an instance of a singleton object.

Try changing Employees.find to Employee.find and see if that clears up  
the  
funkiness.

Also, this might be way off, but some attribute names can cause problems  
with  
ActiveRecord. Attributes that have the same name as internal  
ActiveRecord  
methods cause sporadic errors. The Rails wiki has a running list of  
pseudo-reserved words known to cause problems with AR:  
[http://wiki.rubyonrails.org/rails/pages/ReservedWords](http://wiki.rubyonrails.org/rails/pages/ReservedWords)

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [October 26, 2008, 1:06pm UTC](https://www.ruby-forum.com/t/update-action-nomethoderror-nil-to-sym/151792/3 "2008-10-26T13:06:26Z")

</div>

Miked,

Basically your var @employee is nil when you pass it to form\_for().  
That means Employees.find(params[:id]) is returning nil (either is not  
working, or the :id doesn’t exist)…

As Patrick put, the model name is not standard (should be Employee)  
and finding by hand may also help.

Cheers, Sazima
