From bd05e36e3bd489a30e76b1c8fcfdee855b7386fa Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 2 May 2014 16:52:57 -0400 Subject: [PATCH] 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 --- lib/acts_as_follower/follower.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/acts_as_follower/follower.rb b/lib/acts_as_follower/follower.rb index a086ebe..16b4259 100644 --- a/lib/acts_as_follower/follower.rb +++ b/lib/acts_as_follower/follower.rb @@ -29,7 +29,8 @@ def follow_count # Does not allow duplicate records to be created. def follow(followable) if self != followable - self.follows.find_or_create_by(followable_id: followable.id, followable_type: parent_class_name(followable)) + params = {followable_id: followable.id, followable_type: parent_class_name(followable)} + self.follows.where(params).first_or_create! end end