[Rails] Re: Combine two collections of objects
I guess so. It just seems to grow endles and the queries for the DB
seem to get more and more complicated.
Well I guess thats the way to go then. Thanks Colin.
I wonder when you hear from Amirite again ;)
On Jul 30, 7:00 pm, Colin Law <clan...@googlemail.com> wrote:
> On 30 July 2011 16:36, Stefano <stefano....@gmail.com> wrote:
>
>
>
>
>
> > Hi guys
>
> > I am not sure if it is actually possible what I am trying to do, but
> > Im sure you can help me with it.
> > Let me start with my models:
>
> > class User < ActiveRecord::Base
> > has_many :wall_posts, :class_name => "Post", :foreign_key =>
> > "wall_id", :order => 'created_at DESC'
> > has_many :invites, :class_name => "Invite", :foreign_key =>
> > "contact_id", :order => 'created_at DESC'
> > end
>
> > Now what I want is to combine this to a sort of stream (facebook
> > style). This works fine if I do it with an array as in:
>
> > def stream
> > stream = wall_posts + invites
> > end
>
> You could use STI and combine the two classes into one table. Then
> the stream would be trivial 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@googlegroups.com.
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home