Module: ActsAsAble::Followable::InstanceMethods
- Defined in:
- lib/acts_as_able/followable.rb
Instance Method Summary collapse
- #followers_by_type(follower_type, options = {}) ⇒ Object
-
#followers_count ⇒ Object
1: 查看某个 模型 关注我的所有对象 2: 查看某个 模型 的某个 实例 是否关注我了.
Instance Method Details
#followers_by_type(follower_type, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/acts_as_able/followable.rb', line 24 def followers_by_type(follower_type, = {}) ids = Follow. where('followable_id' => self.id, 'followable_type' => class_name(self), 'follower_type' => follower_type.name ).pluck('follower_id') return follower_type.where("id in (?)", ids) end |
#followers_count ⇒ Object
1: 查看某个 模型 关注我的所有对象2: 查看某个 模型 的某个 实例 是否关注我了
20 21 22 |
# File 'lib/acts_as_able/followable.rb', line 20 def followers_count self.followers.count end |