Reblog a post when user repost from another user timeline

88 Views Asked by At

I need to enable a functionality like tumblr or similar blogs, where the the user can see the original poster (creator) and the user who reposted.

e.g. User A create a post1, User B 'repost' post1, User C discovered post1, because he follow user B or whatever. So user C must see 'post1, posted by User A, reposted by UserB... and so on if user C repost post1.

Currently user can like a micropost, but I also need to be able to 're_like' a micropost.

Firs I need to know the post belongs to reposter user.

I've seen some approach where we have different urls depending on user who reposted.

original ./post/1/ reposted ./post/1/reposted/18 (I guess 18 is repost_id or reposter_id)

My Models:

class User < ActiveRecord::Base
  has_many :microposts, dependent: :destroy
  has_many :likes
  has_many :liked_posts, through: :likes, source: :micropost, dependent: :destroy

class Like < ActiveRecord::Base
  belongs_to :user
  belongs_to :micropost
  has_many :likes

class Micropost < ActiveRecord::Base
  belongs_to :user
  has_many :likes
  has_many :liking_users, through: :likes, source: :user, dependent: :destroy

Rails 4.2.0

0

There are 0 best solutions below