I am trying to create a drop down of categories and that same drop down should also have subcategories of currently selected category. for category drop down I use something like <%= collection_select(:category, :id, Category.find(:all), :id, :name) %> but I would like to do something like <%= collection_select(:category, :id, Category.find(:all).each do |cat| if cat.name?(currently_selected) Subcategory.find(:cat.name), :id, :name) %> any ideas?. -- 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 -~----------~----~----~----~------~----~------~--~---
On Sun, Dec 21, 2008 at 6:41 AM, Rails List <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I am trying to create a drop down of categories and that same drop down > should also have subcategories of currently selected category.I think the closest you can come to this with real HTML would be using `option_groups_from_collection_for_select`; subcategories will be selectable but not categories. And that''s just the way ''optgroup'' works, nothing to do with Rails. HTH! -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---