ActionView::Template::Error (undefined method `model_name' for
NilClass:Class):
1: <%= form_for(@employee) do |e| %>
2: EMP ID<%= e.text_field :id %><br>
3: <%= e.submit 'search', :controller => 'employees', :action =>
'search1' %>
4: <% end %>
in my search action i dint provide anything like
def search
end
if i use <%= form_for(:employee) do |e| %>
it shows no error but the data is moving in to my "show" action
I got nothing in my action search and linked the search button to
search1 action, which contains the find function is that a problem?
Yes. Here is the order of what happens:
1) The browser sends a request that hits the action connected to your
view.
2) The action executes and the view containing your form is processed by
rails and sent to the browser.
3) All variables in your app and their values are destroyed.
4) The user fills out the form and clicks the submit button, which sends
the request to your search1 action, causing the code in search1 to
execute.
So any code in the search1 action executes long after rails processes
the view. In your view, you referenced the @employee variable, so that
view's action has to assign a value to @employee.