Rails activity feed from a polymorphic following
I'm tracking the following tables: Story (id, user_id, content) Vote (id, user_id, story_id) Flag (id, user_id, story_id) etc.. with an activity table: Activity (id, user_id,action, trackable_id,...
View ArticleAnswer by IBueno for Rails activity feed from a polymorphic following
To solve this, I'd search into Activity using votes and flags id's instead of user id's. Something like this: def get_votes(current_user) stories = current_user.stories votes = Votes.where(story_id:...
View ArticleAnswer by Sandip Ransing for Rails activity feed from a polymorphic following
I suggest you have following class definitions and associations: # User class User :trackable end # Flag (id, user_id, story_id) class Flag :trackable end # with an activity table: # Activity (id,...
View ArticleAnswer by Sergey Moiseev for Rails activity feed from a polymorphic following
What about making Activity STI class? class Story < ActiveRecord::Base belongs_to :user end class Activity < ActiveRecord::Base belongs_to :story belongs_to :user end class Vote < Activity def...
View Article