Skip to content

Commit

Permalink
Compare Gem::Version rather than version strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredbeck authored and gregmolnar committed Aug 18, 2019
1 parent aada895 commit b62494b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/ransack/adapters/active_record/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def join_sources
base, joins =
if ::ActiveRecord::VERSION::STRING > Constants::RAILS_5_2_0
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, @object.table.name, [])
constraints = if ::ActiveRecord::VERSION::STRING >= Constants::RAILS_6_0
constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
@join_dependency.join_constraints(@object.joins_values, alias_tracker)
else
@join_dependency.join_constraints(@object.joins_values, @join_type, alias_tracker)
Expand Down Expand Up @@ -281,7 +281,7 @@ def build_joins(relation)
end
else
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, relation.table.name, join_list)
join_dependency = if ::ActiveRecord::VERSION::STRING >= Constants::RAILS_6_0
join_dependency = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::OuterJoin)
else
Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins)
Expand Down Expand Up @@ -313,15 +313,15 @@ def find_association(name, parent = @base, klass = nil)
end

def build_association(name, parent = @base, klass = nil)
if ::ActiveRecord::VERSION::STRING >= Constants::RAILS_6_0
if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
jd = Polyamorous::JoinDependency.new(
parent.base_klass,
parent.table,
Polyamorous::Join.new(name, @join_type, klass),
@join_type
)
found_association = jd.instance_variable_get(:@join_root).children.last
elsif ::ActiveRecord::VERSION::STRING < Constants::RAILS_5_2_0
elsif ::Gem::Version.new(::ActiveRecord::VERSION::STRING) < ::Gem::Version.new(Constants::RAILS_5_2_0)
jd = Polyamorous::JoinDependency.new(
parent.base_klass,
Polyamorous::Join.new(name, @join_type, klass),
Expand Down

0 comments on commit b62494b

Please sign in to comment.