I am trying to setup a model where a user can post an advertisement and along with other information such as the ad content, they will be allowed to use checkboxes in the form to select a few options/categories of what their advertisement is looking for.
For example,
“Looking for washer and dryer” then they can click the checkboxes for ‘Appliances, Home` and maybe some other that they feel their ad applies to.
The problem is, I haven’t even setup my model yet. What is the best way to have my model hold the categories that the user picks?
This video is exactly what you’re looking for.
Have a HABTM relationship.
So you have a table called Ads, and a table called Categories. Make a table called AdCategories, where each record has only two fields: an ad_id and a category_id. So each record links an ad to a category.
More info on HABTM can be found here.