Hi everyone, i have the following code: <%= form_tag :action => ''list_wedding_by_continent'', :id => "Africa" %> <%= collection_select(:thing, :continent, @continent,"id","continent") %> <%= submit_tag ''Search'' %> <%= end_form_tag %> how do i pass in the selected country in the list, instead of hard coding "Africa" thank you -- 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 -~----------~----~----~----~------~----~------~--~---
can anyone help me? -- 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 -~----------~----~----~----~------~----~------~--~---
pingu wrote:> Hi everyone, i have the following code: > > <%= form_tag :action => ''list_wedding_by_continent'', :id => "Africa" %> > <%= collection_select(:thing, :continent, @continent,"id","continent") > %> > <%= submit_tag ''Search'' %> > <%= end_form_tag %> > > how do i pass in the selected country in the list, instead of hard > coding "Africa" > thank you > >Forget the rails helpers for a moment and go back to HTML basics. You''ve got a form (which rails can help you create using form_tag, or even better, form_for). This submits a post request to a URL (which in the rails helper can be generated with a hash of parameters, including perhaps :action => ''some_action''). The contents of that form (including, as in your case, a select box, which rails can help you create with select, select_tag, collection_select, etc) are passed to the receiving URL for it to do with what it wants. There''s no way (short of some javascript) that the chosen option of the select box can end up the url the form is submitting to, which I think is what you''re asking. Have a play around with the helpers and examine the source code they produce in your browser, or check out the API. It will all become clear.... eventually. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Chris T, and i really appreciate you taking the time to explain it to me. But i am still confused, if there is no way to get the information out of a form, whats the point of it? -- 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 -~----------~----~----~----~------~----~------~--~---
You should get the selected continent coming through as things are (just inspect the contents of the params hash that is passed to your controller. However I think you''re expecting params[:id] to contain the selected continent This won''t happen because - I think that having :id => ''Africa'' in form_tag will effectively mean that it''s overriden - collection_select (like the various other helpers of its family) will put the selected parameter in params[:thing][:continent] (Check out the html that is generated by your form Fred -- 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 -~----------~----~----~----~------~----~------~--~---
Great, thanks Fred - sorted it. -- 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 -~----------~----~----~----~------~----~------~--~---