Commit f41fc191e9459926878eadcdf9b69875451a8fe3

Authored by Justin Reese
1 parent feadb8f2
Exists in master

Uses first_or_create in Follower#follow

Uses first_or_create! instead of deprecated find_or_create. Old way
causes #follow to fail in certain Rails versions

first_or_create is available since Rails 3.2, find_or_create is
deprecated in Rails 4.0
Showing 1 changed file with 2 additions and 1 deletions   Show diff stats
lib/acts_as_follower/follower.rb
... ... @@ -29,7 +29,8 @@ module ActsAsFollower #:nodoc:
29 29 # Does not allow duplicate records to be created.
30 30 def follow(followable)
31 31 if self != followable
32   - self.follows.find_or_create_by(followable_id: followable.id, followable_type: parent_class_name(followable))
  32 + params = {followable_id: followable.id, followable_type: parent_class_name(followable)}
  33 + self.follows.where(params).first_or_create!
33 34 end
34 35 end
35 36  
... ...