2017-07-17 85 views
1

我正在开发一个Rails应用,用户可以在其中跟踪tag。我正在使用acts_as_taggableacts_as_follower,但我不知道如何继续。关注(acts_as_follower)标签(acts_as_taggable_on)

用户模式

class User < ApplicationRecord 

acts_as_follower 

end 

帖子模式

class Post < ApplicationRecord 
belongs_to :user 
acts_as_taggable_on :tags 
end 

但我应该在哪里把acts_as_followable

回答

0

您应该将acts_as_followable放在您希望用户能够遵循的任何项目上。在这种情况下,我假设你希望用户能够按照职位,所以:

class Post < ApplicationRecord 
belongs_to :user 
acts_as_taggable_on :tags 
acts_as_followable 
end 

记住这个宝石完全无关的acts_as_taggable_on宝石。他们做不同的事情,不默认交互。

+0

感谢您的回复! 但我想要的是用户遵循标签,而不是帖子。 –

+0

@JuniorMiranda哦,我错过了,对不起!一秒。 – eiko

相关问题