Modelling question

Hi,

I have these 3 models:
City :name
Product :name
city_preference :city_id, :product_id, :min, :max

How do i create the associations between these tables?
Best
Greg

Look up has_many and belongs_to

On 8 March 2010 21:03, Greg Ma [email protected] wrote:

Hi,

I have these 3 models:
City :name
Product :name
city_preference :city_id, :product_id, :min, :max

How do i create the associations between these tables?

Have a look at the rails guide on ActiveRecord Associations at
http://guides.rubyonrails.org. Also Getting Started, Debugging and
the others if you have not already worked through them.

Also don’t think about tables first, think about the real world
objects you are modeling and what there relationships and attributes
are. That will then allow you to define the tables and associations.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs