diff --git a/lib/flipper/adapters/active_record.rb b/lib/flipper/adapters/active_record.rb index cb876bf30..752a1c00f 100644 --- a/lib/flipper/adapters/active_record.rb +++ b/lib/flipper/adapters/active_record.rb @@ -130,7 +130,9 @@ def get_all rows_query = features.join(gates, ::Arel::Nodes::OuterJoin) .on(features[:key].eq(gates[:feature_key])) .project(features[:key].as('feature_key'), gates[:key], gates[:value]) - gates = @feature_class.connection.select_rows(rows_query) + select_method = rails_version_over_4_2? ? :select_rows : :select_all + gates = @feature_class.connection.send(select_method, rows_query) + # group the gates by feature key grouped_gates = gates.inject({}) do |hash, (feature_key, key, value)| @@ -149,6 +151,10 @@ def get_all end end + def rails_version_over_4_2? + Rails::VERSION::MAJOR * 10 + Rails::VERSION::MINOR > 42 + end + # Public: Enables a gate for a given thing. # # feature - The Flipper::Feature for the gate.