from the API: ***************************** collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {}) ***************************** So how would one get the params of this collection_select? 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 -~----------~----~----~----~------~----~------~--~---
no idea what you want .... i#ll just give an example: <%= collection_select :post, :category, @categories, :id, :name, {:include_blank => true } %> will generate <select name="post[category]"> <option><option> <option value="1">Diary<option> <option value="2">Technical<option> <option value="3">Rants<option> </select> - object + method form the name="post[category]" - the collection has the input for the option tags. - value_method is the method to use on the collection items to get the value for value="" here: @categories.id - text_method is the method to use on the collection items to get the display text for the options here: @categories.name - the options hash take the options as explained in the API docs of FormOptionsHelpers, e.g. the :include_blank i used above to create an empty <option> tag - the html options hash takes the usua stuff like :class => "something" etc.... when the form is submitted, you can access the selected value with params[:post][:category] --~--~---------~--~----~------------~-------~--~----~ 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 write a book. Nobody explained it like this before. Thanks a lot. -- 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 I just say that I have spent the last day or so working this out, and you solved it for me. In my controller, I have been trying to use: @shipping_cost = ShippingCost.find(params[:shipping_cost][:id]) and all I get is an issue of: Couldn''t find ShippingCost with ID So now I switched to the form of: @shipping_cost = params[:shipping_cost][:id] and it works fine. The only problem is I dont know why. Do you know why your method works and my original one does not? Thanks in advance!!!! Thorsten L wrote:> no idea what you want .... i#ll just give an example: > > <%= collection_select :post, :category, @categories, :id, :name, > {:include_blank => true } %> > > will generate > > <select name="post[category]"> > <option><option> > <option value="1">Diary<option> > <option value="2">Technical<option> > <option value="3">Rants<option> > </select> > > - object + method form the name="post[category]" > - the collection has the input for the option tags. > - value_method is the method to use on the collection items to get the > value for value="" > here: @categories.id > - text_method is the method to use on the collection items to get the > display text for the options > here: @categories.name > > - the options hash take the options as explained in the API docs of > FormOptionsHelpers, e.g. the :include_blank i used above to create an > empty <option> tag > - the html options hash takes the usua stuff like :class => "something" > etc.... > > when the form is submitted, you can access the selected value with > params[:post][:category]-- 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 -~----------~----~----~----~------~----~------~--~---