Skip to content

Commit

Permalink
Merge pull request #1165 from activerecord-hackery/adapt_to_quoting_c…
Browse files Browse the repository at this point in the history
…hange

Adapt to quoting change in Rails
  • Loading branch information
deivid-rodriguez authored Nov 20, 2020
2 parents 4980d02 + 93615c3 commit b8f12bb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/ransack/adapters/active_record/ransack/nodes/condition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,19 @@ def in_predicate?(predicate)
end

def casted_array?(predicate)
predicate.respond_to?(:val) && predicate.val.is_a?(Array)
(predicate.respond_to?(:value) && predicate.value.is_a?(Array)) || # Rails 6.1
(predicate.respond_to?(:val) && predicate.val.is_a?(Array)) # Rails 5.2, 6.0
end

def format_values_for(predicate)
predicate.val.map do |value|
value.is_a?(String) ? Arel::Nodes.build_quoted(value) : value
value = if predicate.respond_to?(:value)
predicate.value # Rails 6.1
else
predicate.val # Rails 5.2, 6.0
end

value.map do |val|
val.is_a?(String) ? Arel::Nodes.build_quoted(val) : val
end
end

Expand Down

0 comments on commit b8f12bb

Please sign in to comment.