ernie/ransack — Issue #72: Apply predicate to a nested Arel node
Author: ml
Created: 2012-02-13 22:13:37+00:00
State: open

I need to apply a predicate to a nested node. Is there any simpler way to achieve this than

```ruby
class Candidate
has_many :candidate_skills

class FakeAttributeForIn
def initialize(&block)
@block = block
end

def in(args)
@block.call args
end
end

ransacker :skills_ids do |parent|
FakeAttributeForIn.new { |args|
cs = CandidateSkill.arel_table
c = Candidate.arel_table

CandidateSkill.where(cs[:skill_id].in(args).and(cs[:candidate_id].eq(c[:id]))).exists
}
end
end

Candidate.search(skills_ids_in: [1, 2, 3]).result

```
?