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
>
>   �[email protected]
>
> how do I do the same thing for a collection called reports of the doc
> type also?

  @echantillon.reports.build

I think.

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.
>
>

-- 
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.

Reply via email to