Ruby on Rails Friday, September 2, 2011



On Fri, Sep 2, 2011 at 5:30 PM, Pab <prabu.net88@gmail.com> wrote:
Hi,


def search

end



 def search1

           @employee = Employee.find(params[:id])
           respond_to do |format|
             format.html{render :partial => 'show'}
             format.xml
           end

 end





search.html is
 <%= form_for(@employee) do |e| %>
 EMP ID<%= e.text_field :id %><br>
 <%= e.submit 'search', :controller => 'employees', :action =>
'search1' %>
 <% end %>


the search method doesn't declare any instance variable but in the view template,
you want to use @employee.  form_for expects @employee to be declared so
that form_for can form the url and the input field names.  so the solution to your
problem is to just declare an @employee in the search action.
 


problem is its not showing up search page itself


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