Hey, Sorry another question that has been bugging me :( How could I reproduce the functionality of: <%= link_to cuisine.name, :action => ''search'', :id => cuisine.id, :sort => "name" %> in a drop down menu with a submit button. basically I want the user to be able to choose a cuisine from a drop-down menu, click "submit" and then that should pass the id to the search action. Thanks! -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
just an update, you can ignore the :sort part, so just: <%= link_to cuisine.name, :action => ''search'', :id => cuisine.id %> -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
First, you''d place the select inside a form and then set the select so that it returns the cuisine.id in the select. Add a submit button and then your method specified in the form tag will receive the id as <%= start_form_tag( {:action => ''select_cuisine''} ) %> <%= select( :cuisine, :id, Cuisine.find_all.collect { |c| [c.name, c.id ] } ) %> <%= submit_tag "Submit" %> <%= end_form_tag %> Then, when the "select_cuisine" method is called the id will be in params[:cuisine][:id]. I didn''t test the code above, but it should give you the idea. David Schmidt Richard wrote:> Hey, > > Sorry another question that has been bugging me :( > > How could I reproduce the functionality of: > > <%= link_to cuisine.name, :action => ''search'', :id => cuisine.id, :sort > => "name" %> > > in a drop down menu with a submit button. basically I want the user to > be able to choose a cuisine from a drop-down menu, click "submit" and > then that should pass the id to the search action. Thanks! > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---