我正在使用acts_as_favorite_updated
一个应用程序来保存许多不同的模型。但是,当我尝试启用“收藏”其他用户时,我遇到了一个奇怪的错误。(很高兴详细解释,但基本上,由于调用冲突,取决于用户模型中acts_as_favorite 和acts_as_favorite_user 的顺序,路由会被耗尽。)
谁能推荐一个像样的插件,让我可以保存/收藏特定模型/对象以及其他用户?
我正在使用acts_as_favorite_updated
一个应用程序来保存许多不同的模型。但是,当我尝试启用“收藏”其他用户时,我遇到了一个奇怪的错误。(很高兴详细解释,但基本上,由于调用冲突,取决于用户模型中acts_as_favorite 和acts_as_favorite_user 的顺序,路由会被耗尽。)
谁能推荐一个像样的插件,让我可以保存/收藏特定模型/对象以及其他用户?
This should cover you: http://ruby.railstutorial.org/chapters/following-users#top
试试这个分叉: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