ernie/ransack — Issue #36: how to use ransacker?
Author: lunks
Created: 2011-10-25 21:57:23+00:00
State: open

I've got an ActiveRecord model with a scope and a ransacker defined like this:

```ruby
scope :by_country_state, lambda {|state|
ddds = City.where(:country_state => state).map{|city| city.ddd}.uniq!
where(:ddd => ddds)
}
ransacker :by_country_state
```

If I try to add `f.text_field :by_country_state` on the view, when I search I get `ArgumentError (No valid predicate for by_country_state)`, if I try to add `f.text_field :by_country_state_eq`, I get:

```ruby
TypeError (Cannot visit ActiveRecord::Associations::JoinDependency::JoinBase):
app/models/telephone.rb:8:in `block in '
```
Line 8 is the second line on my former blockquote.

I'm following this behavior from meta_search search_methods, so I might be taking the wrong approach, but I couldn't figure it out from the specs or the code. Could you help me, please?