Commit 0e46dd1f84a09f532f3117bf5d9f0f57b8b5126f
1 parent
3be81a7d
Exists in
master
and in
3 other branches
Added a faster version of following_by_type.
Showing
1 changed file
with
2 additions
and
1 deletions
Show diff stats
lib/acts_as_follower.rb
... | ... | @@ -65,7 +65,8 @@ module ActiveRecord #:nodoc: |
65 | 65 | |
66 | 66 | # Returns the actual records of a particular type which this record is following. |
67 | 67 | def following_by_type(followable_type) |
68 | - follows_by_type(followable_type).map { |f| f.followable} | |
68 | + klass = eval(followable_type) # be careful with this. | |
69 | + klass.find(:all, :joins => :follows, :conditions => ['follower_id = ? AND follower_type = ?', self.id, self.class.name]) | |
69 | 70 | end |
70 | 71 | |
71 | 72 | # Allows magic names on following_by_type | ... | ... |