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? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2010-Mar-31 11:31 UTC
Re: object has two collections of objects of the same type
On 31 March 2010 12:09, ES <emstolfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > > -UwJ4gR2mK0RxaEK+BLf+O8GLU5RzS1PE@public.gmane.org > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.