Skip to content

Commit

Permalink
No need pass the some arugments to JoinAssociation#join_constraints i…
Browse files Browse the repository at this point in the history
…n rails 5.1

refs
- rails/rails#28267
- rails/rails#27851
  • Loading branch information
ta1kt0me committed Jul 11, 2017
1 parent c9eff61 commit 256f75f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
28 changes: 19 additions & 9 deletions lib/ransack/adapters/active_record/context.rb
Expand Up @@ -342,15 +342,25 @@ def build_association(name, parent = @base, klass = nil)
def extract_joins(association)
parent = @join_dependency.join_root
reflection = association.reflection
join_constraints = association.join_constraints(
parent.table,
parent.base_klass,
association,
Arel::Nodes::OuterJoin,
association.tables,
reflection.scope_chain,
reflection.chain
)
join_constraints = if ::ActiveRecord::VERSION::STRING < Constants::RAILS_5_1
association.join_constraints(
parent.table,
parent.base_klass,
association,
Arel::Nodes::OuterJoin,
association.tables,
reflection.scope_chain,
reflection.chain
)
else
association.join_constraints(
parent.table,
parent.base_klass,
Arel::Nodes::OuterJoin,
association.tables,
reflection.chain
)
end
join_constraints.to_a.flatten
end

Expand Down
1 change: 1 addition & 0 deletions lib/ransack/constants.rb
Expand Up @@ -46,6 +46,7 @@ module Constants
CONT = 'cont'.freeze

RAILS_4_1 = '4.1'.freeze
RAILS_5_1 = '5.1'.freeze

RANSACK_SLASH_SEARCHES = 'ransack/searches'.freeze
RANSACK_SLASH_SEARCHES_SLASH_SEARCH = 'ransack/searches/search'.freeze
Expand Down

0 comments on commit 256f75f

Please sign in to comment.