What is the best way to add categories to posts - Ruby on Rails blog...
- by bgadoci
I am new to Ruby and Rails so bear with me please. I have created a very simple blog application with both posts and comments. Everything works great. My next question regarding adding categories. I am wondering the best way to do this. As I can't see too far in front of me yet when it comes to Rails I thought I would ask.
To be clear, I would like that a single post can have multiple categories and a category can have multiple posts.
Is the best way to do this to create a 'categories' table and then use the posts and categories models to do has_many :posts, has_many :categories? Would I also then set the routes.rb such that posts are embedded under categories?
Or is there an easier way by simply adding a category column to the existing posts table? (in which case I would imagine having multiple categories would be difficult).