Commit 4e7e6e6e1d50f6bfdbc8c614655c7d8f7fcf5933

Authored by Jonathan George
1 parent d2604e8c

: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,14 +24,15 @@ module ActiveRecord
24 24
25 # Returns the following records. 25 # Returns the following records.
26 def followers 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 end 29 end
29 30
30 # Returns true if the current instance is followed by the passed record. 31 # Returns true if the current instance is followed by the passed record.
31 def followed_by?(follwer) 32 def followed_by?(follwer)
32 rtn = false 33 rtn = false
33 self.follows.each do |f| 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 end 36 end
36 rtn 37 rtn
37 end 38 end