Ask A Question

Notifications

You’re not receiving notifications from this thread.

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

Charles Smith asked in Rails

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.

Reply

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

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.