Does something like this work for you?
@friends = Favorite.find_all_by_user_id_and_favorable_type(current_user.id, 'User')
@friend_blogs = @friends.blog_posts.find( :all, :order => "created_at DESC", :limit => 5)
Does something like this work for you?
@friends = Favorite.find_all_by_user_id_and_favorable_type(current_user.id, 'User')
@friend_blogs = @friends.blog_posts.find( :all, :order => "created_at DESC", :limit => 5)
I dont like the first query, it would fall into method missing and that takes alot of overhead to create it. I would instead write it as.
@friends = Favorite.find(:all, :conditions => ["user_id = ? and favorable_type = 'User' " , current_user.id)
WW
The overhead of method_missing would be greatly outweighed by the cost of the database query. Premature optimization is the root of all evil.
///ark