On 11 November 2010 18:05, Dani Dani <[email protected]> wrote: > Marnen Laibow-Koser wrote in post #960765: >> >> Associate each record with a company. >> >>> > Thank you Marnen. So it means each record should have an extra field to > associate a record with a certain company. I had this also in mind, but > I thought there are other better ways than this. > > Any more Ideas ?
You may not need to associate everything to the company of course. For example, if the company has products and each product has drawings then you would use Company has_many products Product belongs_to company Product has_many drawings Drawing belongs_to product So Product has a company_id field to tie it to a company and Drawing has a product_id field to tie it to a product. There is therefore no need to associate the drawing to the company as this is already implied by the other associations. Have a look at the Rails Guide on ActiveRecord Associations if this is new stuff for you. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

