Skip to main content

What type of association should I choose...I'm lost in the woods.

Rails • Asked by Charles Smith

I cannot for the life of me figure out the best model association to choose and I've thought myself into a corner. I'm building a site for a client that offers party services for four(4) locations in Southern California.

For this, I have three(3) models - Locations, Categories, Products.

Here are some URL examples:

http://somewebsite.com/san-diego/birthday-parties/boy-themed
http://somewebsite.com/orange-county/birthday-parties/boy-themed
http://somewebsite.com/los-angeles/birthday-parties/boy-themed
http://somewebsite.com/riverside/birthday-parties/boy-themed

The products model will have 4 price columns and the price on the page will be determined by the /location-url/ and will be displayed with jQuery. Other than that all the models are shared with the only caveate is that a Product has to belong to a category and location, but I want to be able to share the Product and Category models with many locations so I don't have to create a duplicate for each location. I hope I am making some sense. Thank you.


Product and Category need to have many locations probably using a through association.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.