You'd have to have some polymorphic columns in an "actions" table,
something like:

id                     #=> 1
comment_id    #=> 15
favourite_id     #=> nil
user_id            #=> 10
created_at      #=> Wed Dec 17 03:14:41 0000 2008

Then you can do something like:

Newsfeed.all(:conditions => { :user_id => 1 }, :include => [:comment,
:favourite], :limit => 25)

…At least I THINK that'd work, but I think it would — something
similar anyhow! :)

On Wed, Dec 24, 2008 at 5:16 PM, Dave Amos
<[email protected]> wrote:
>
> Ashley Williams wrote:
> > You could also create an Actions model which has_many
> > favourites/comments/ect. which seems like a more sensible solution; it'd
> > join and include all the data from the sources tables for you in one
> > query.
> > :)
> >
> > On Wed, Dec 24, 2008 at 4:19 PM, Dave Amos
> > <[email protected]
>
> Clever! I'm not sure I'm clever enough to implement it correctly,
> though. I created a Newsfeed model and did the has_many/belong_to stuff,
> but I'm not sure how to do my controller code.
>
> Lets say I wanted to have a feed of all actions a user takes (comments,
> recipes posted, favorites, etc.). I tried:
>
> @feed = Newsfeed.find(:all, :conditions => ["user_id = ?", @user.id])
>
> But I get this error: Mysql::Error: #42S02Table
> 'cookingfriend_development.newsfeeds' doesn't exist: SELECT * FROM
> `newsfeeds`
>
> I think I need a database? How else do I query the model?
> --
> Posted via http://www.ruby-forum.com/.
>
> >

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