Categorizations for Ruby on Rails (or tags)
I have Articles, Profiles, and Comments. What would be the best way to categorize new instances of each of these? When a user creates a new article, profile, or comment, he must select a category for them. I want to have a drop down menu from which he can select the categories. The categories are different 开发者_Go百科for each Model, and what categories appear in one model cannot appear in another. Thank you.
As for categories or 'tags', I recommend this gem,
http://github.com/TylerRick/acts_as_taggable .
Seems to be a reasonable fit for you.
For the drop down menu, I would follow this blog here:
http://www.softiesonrails.com/2008/4/10/absolute-moron-s-guide-to-forms-in-rails-part-5
That's what got me started in making complex drop downs made out of dynamic models. That section, Part 5 speaks specifically about what you're asking, but you may have to backtrack to part 1 ( I recommend it ), to see how he built up to it.
Good luck!
精彩评论