Forum: Ruby on Rails multi-select category listbox

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
760e5c90000057a6860986b69b77c400?d=identicon&s=25 John Griffiths (indiehead)
on 2008-10-19 20:19
Hi, on to the final bit of my blogging engine and would really
appreciate a pointer in the right direction.

With each article they can be associated with multiple categories, so
inside the admin panel I need to somehow have a listbox that allows
users to select multiple categories and associated them to an article.

Now I can return an object of all the categories available and one that
contains all the categories the current article is associated, putting
that in a listbox and making it save the results is what stumps me.

any ideas?
4c438a80fc30661ad619ea177cf9cbd0?d=identicon&s=25 Freddy Andersen (Guest)
on 2008-10-19 22:33
(Received via mailing list)
select_tag “article[category_ids][]“,
options_from_collection_for_select(@available_categories, “id”,
“name”), :multiple=>true

That should create a select box with multiple selected elements...
This topic is locked and can not be replied to.