Form_tag for search bar with Rails 3.0.5

I have a controller and view that should be providing a search bar
that brings up that brings up a selected record on submission. I have
tried several variations, including just specifying the assets_path,
but usually end up with either an error or a submission to the index
action, rather than the show action. Currently, I have the following
in my index.html.haml:

= form_tag({:controller => ‘assets’, :action => ‘show’}, :method
=> :GET) do
.field
=label_tag(‘Job
Number’).titleize

%br/

=number_field_tag :id
.actions
=submit_tag ‘Search’, :name => nil

This gives me the following error:

No route matches {:controller=>“assets”, :action=>“show”}

$ rake routes | fgrep asset )
assets GET /
assets(.:format)
{:action=>“index”, :controller=>“assets”}
POST /
assets(.:format)
{:action=>“create”, :controller=>“assets”}
new_asset GET /assets/
new(.:format)
{:action=>“new”, :controller=>“assets”}
edit_asset GET /assets/:id/
edit(.:format)
{:action=>“edit”, :controller=>“assets”}
asset GET /
assets/:id(.:format)
{:action=>“show”, :controller=>“assets”}
PUT /
assets/:id(.:format)
{:action=>“update”, :controller=>“assets”}
DELETE /
assets/:id(.:format)
{:action=>“destroy”, :controller=>“assets”}

How can I get a form_tag to take the user to /asset/123 (or whatever)
as intended?

On Mar 8, 10:44am, “Todd A. Jacobs” [email protected]
wrote:

=label_tag('Job
No route matches {:controller=>“assets”, :action=>“show”}
Routing happens based on the url, not on form parameters. You might
try posting to a search action that would bounce them to the
appropriate show action. Equally you could wire up some javascript to
craft the correct url client side.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs