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
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.