Commit 4e7e6e6e1d50f6bfdbc8c614655c7d8f7fcf5933
1 parent
d2604e8c
Exists in
master
and in
3 other branches
:include the follower for followers(), use parent_class_name.
Showing
1 changed file
with
3 additions
and
2 deletions
Show diff stats
lib/acts_as_followable.rb
... | ... | @@ -24,14 +24,15 @@ module ActiveRecord |
24 | 24 | |
25 | 25 | # Returns the following records. |
26 | 26 | def followers |
27 | - self.follows.collect{ |f| f.follower } | |
27 | + Follow.find(:all, :include => [:follower], :conditions => ["followable_id = ? AND followable_type = ?", | |
28 | + self.id, parent_class_name(self)]).collect {|f| f.follower } | |
28 | 29 | end |
29 | 30 | |
30 | 31 | # Returns true if the current instance is followed by the passed record. |
31 | 32 | def followed_by?(follwer) |
32 | 33 | rtn = false |
33 | 34 | self.follows.each do |f| |
34 | - rtn = true if follwer.id == f.follower_id && follwer.class.name == f.follower_type | |
35 | + rtn = true if follwer.id == f.follower_id && parent_class_name(follwer) == f.follower_type | |
35 | 36 | end |
36 | 37 | rtn |
37 | 38 | end | ... | ... |