Object has two collections of objects of the same type

I want to have my object class have both a collection of doc objects
called “reports” and one called “docs”. How do I specify two
different arrays of the same type of object?

I have this in my new method

@echantillon.docs.build

how do I do the same thing for a collection called reports of the doc
type also?

On 31 March 2010 12:09, ES [email protected] wrote:

I want to have my object class have both a collection of doc objects
called “reports” and one called “docs”. How do I specify two
different arrays of the same type of object?

class Whatever < ActiveRecord.Base
has_many :docs
has_many :reports, class_name => “Doc”, foreign_key => “something_id”

whatever_id is a field in docs

class Doc < ActiveRecord::Base
belongs_to :whatever
belongs_to :something, class_name => Whatever

Then you can say whatever.docs, whatever.reports and doc.whatever and
doc.something

I have this in my new method

@echantillon.docs.build

how do I do the same thing for a collection called reports of the doc
type also?

@echantillon.reports.build

I think.

Colin