【问题标题】:Follow(acts_as_follower) a tag(acts_as_taggable_on)关注(acts_as_follower)标签(acts_as_taggable on)
【发布时间】:2017-07-17 18:52:28
【问题描述】:

我正在开发一个 Rails 应用程序,用户可以在其中关注tag。我正在使用acts_as_taggableacts_as_follower,但我不知道如何继续。

用户模型

class User < ApplicationRecord

 acts_as_follower

end

帖子模型

class Post < ApplicationRecord
 belongs_to :user
 acts_as_taggable_on :tags
end

但是我应该把acts_as_followable放在哪里?

【问题讨论】:

    标签: ruby-on-rails ruby acts-as-taggable-on acts-as-follower


    【解决方案1】:

    您应该将acts_as_followable 放在您希望用户能够关注的任何内容上。在这种情况下,我假设您希望用户能够关注帖子,所以:

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

    请记住,此 gem 与 acts_as_taggable_on gem 完全无关。它们做不同的事情,默认情况下不交互。

    【讨论】:

    • 感谢您的回复!但我想要的是用户关注标签,而不是帖子。
    • @JuniorMiranda 哦,我错过了,对不起!一秒钟。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多