title: Ransack: How to use existing scope?
body: <p>Converting a Rails 2 application to Rails 3, I have to replace the gem <a href="https://github.com/binarylogic/searchlogic">searchlogic</a>. Now, using Rails 3.2.8 with the gem <a href="https://github.com/ernie/ransack">Ransack</a> I want to build a search form which uses an existing scope. Example:</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    scope :year, lambda { |year| 
      where("posts.date BETWEEN '#{year}-01-01' AND '#{year}-12-31'") 
    }
  end  
  </code></pre>
  
  <p>So far as I know, this can be achieved by defining a custom <a href="http://rdoc.info/github/ernie/ransack/Ransack/Ransacker">ransacker</a>. Sadly, I don't find any documentation about this. I tried this in the <code>Post</code>class:</p>
  
  <pre><code>ransacker :year, 
            :formatter =&gt; proc {|v| 
              year(v)
            }
  </code></pre>
  
  <p>But this does not work:</p>
  
  <pre><code>Post.ransack(:year_eq =&gt; 2012).result.to_sql
  =&gt; TypeError: Cannot visit ActiveRecord::Relation
  </code></pre>
  
  <p>I tried some variations of the <code>ransacker</code> declaration, but none of them work. I Need some help...</p>
  
  <p><strong>UPDATE:</strong> The scope above is just on example. I'm looking for a way to use every single existing scope within Ransack. In MetaSearch, the predecessor of Ransack, there is a feature called <code>search_methods</code> for using scopes. Ransack has <a href="https://github.com/ernie/ransack/issues/61">no support for this</a> out of the box yet.</p>