【问题标题】:Best rails plugin to save/favorite other users?保存/收藏其他用户的最佳 Rails 插件?
【发布时间】:2010-11-19 13:32:25
【问题描述】:

我在一个应用上使用acts_as_favorite_updated 来保存许多不同的模型。但是,当我尝试启用“收藏”其他用户时,我遇到了一个奇怪的错误。 (很高兴详细解释,但基本上,由于根据用户模型中的acts_as_favorite 和acts_as_favorite_user 的顺序而发生冲突的调用,路由会被耗尽。)

谁能推荐一个不错的插件,让我可以保存/收藏特定模型/对象以及其他用户?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-plugins favorites


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      试试这个分叉:https://github.com/beno/acts_as_favorite

      在您的Gemfile 中添加:gem 'acts_as_favorite', github: 'beno/acts_as_favorite'

      它为模型(最有可能是用户)提供方法来支持(也就是跟随)另一个模型。

      例如,current_user.favor product

      单元测试应该让用法更清晰:https://github.com/beno/acts_as_favorite/blob/master/spec/acts_as_favorite_spec.rb

      另外,acts_as_follower gem 正在积极开发中。

      https://github.com/tcocca/acts_as_follower

      class Product < ActiveRecord::Base
        acts_as_followable
      end
      
      class User < ActiveRecord::Base
        acts_as_followable
        acts_as_follower
      end
      

      然后发出user.follow product

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-10-20
        • 1970-01-01
        • 1970-01-01
        • 2011-10-17
        • 1970-01-01
        • 1970-01-01
        • 2015-08-13
        • 1970-01-01
        相关资源
        最近更新 更多