Ruby on Rails Friday, September 2, 2011



On Fri, Sep 2, 2011 at 6:31 PM, Pab <prabu.net88@gmail.com> wrote:
hi

def search
 @employee
end

i have done the above, but it shows following error

undefined method `model_name' for NilClass:Class

Extracted source (around line #1):

1: <%= form_for(@employee) do |e| %>
2: <%= e.error_msg %>
3: EMP ID<%= e.text_field :id %><br>
4: <%= e.submit 'search', :controller => 'employees', :action =>
'search1' %>


you need to set @employee to something, not just declare it like that in the controller.

@employee = Employee.new #or some other model
 

thanks,
-pab

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.




--
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment