Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Fix to make active_record adapter work with 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
astupka committed Apr 25, 2024
1 parent 55db302 commit 8c294b2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/flipper/adapters/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)|
Expand All @@ -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.
Expand Down

0 comments on commit 8c294b2

Please sign in to comment.