From 81d79904f0332951417d8923286c7297af9021b3 Mon Sep 17 00:00:00 2001 From: Nick Pafundi Date: Fri, 22 Jan 2016 18:33:12 -0800 Subject: [PATCH] Include ActiveRecord versions above 3.0 In a polymorphic relationship on ActiveRecord 4+, this conditional would result in a `nil` reference class, because it would fall back to the pre-3.0 options rather than using the reflection's `foreign_type`. This change checks for major version 3+ rather than only 3. --- lib/replicate/active_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/replicate/active_record.rb b/lib/replicate/active_record.rb index 6acdcee..2896a66 100644 --- a/lib/replicate/active_record.rb +++ b/lib/replicate/active_record.rb @@ -77,7 +77,7 @@ def replicate_reflection_info(reflection) options = reflection.options if options[:polymorphic] reference_class = - if ::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR > 0 + if ::ActiveRecord::VERSION::MAJOR >= 3 && ::ActiveRecord::VERSION::MINOR > 0 attributes[reflection.foreign_type] else attributes[options[:foreign_type]]