开发者

Best rails plugin to save/favorite other users?

开发者 https://www.devze.com 2023-01-26 12:03 出处:网络
I\'m using acts_as_favorite_updated on an app to save a number of different models. However, when I try to enable \"favoriting\" other users, I\'m running in to a strange error. (Happy to expl开发者_如

I'm using acts_as_favorite_updated on an app to save a number of different models. However, when I try to enable "favoriting" other users, I'm running in to a strange error. (Happy to expl开发者_如何学编程ain in detail, but basically the routes get f-ed up due to conflicting calls depending on the order of acts_as_favorite and acts_as_favorite_user in the User model.)

Can anyone recommend a decent plugin that will allow me to save/favorite specific models/objects as well as other users?


This should cover you: http://ruby.railstutorial.org/chapters/following-users#top


Try this fork: https://github.com/beno/acts_as_favorite

In your Gemfile, add this: gem 'acts_as_favorite', github: 'beno/acts_as_favorite'

It provides methods for a model (most likely User) to favor (a.k.a. follow) another model.

For example, current_user.favor product

The unit tests should make the usage more clear: https://github.com/beno/acts_as_favorite/blob/master/spec/acts_as_favorite_spec.rb

Alternatively, the acts_as_follower gem is under active development.

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

Then issue a user.follow product

0

精彩评论

暂无评论...
验证码 换一张
取 消