title: ransack using ransacker for integer to_char
body: <p>I'm attempting to use the ransacker method to convert one of my fields from integer to string with the following</p>
  
  <pre><code>ransacker :invoice_no do
    Arel.sql("to_char(invoice_no, '9999999')")
  end
  </code></pre>
  
  <p>I'm using PostgeSQL 9.1 and I've tested doing it manually in psql like below, which works</p>
  
  <pre><code>select to_char(invoice_no, '9999999') AS invoice_no from invoices;
  </code></pre>
  
  <p>The error I get when trying to search ransack using :invoice_no_cont is</p>
  
  <pre><code>  Invoice Load (1.3ms)  SELECT "invoices".* FROM "invoices" WHERE "invoices"."ledger_id" = 2 AND (to_char(invoice_no, '9999999') ILIKE 0) ORDER BY invoice_no desc LIMIT 10 OFFSET 0
  PG::UndefinedFunction: ERROR:  operator does not exist: text ~~* integer
  LINE 1: ...edger_id" = 2 AND (to_char(invoice_no, '9999999') ILIKE 0) O...
                                                               ^
  HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
  : SELECT  "invoices".* FROM "invoices"  WHERE "invoices"."ledger_id" = 2 AND (to_char(invoice_no, '9999999') ILIKE 0) ORDER BY invoice_no desc LIMIT 10 OFFSET 0
    Rendered invoices/index.json.rabl (3.6ms)
  Completed 500 Internal Server Error in 12.3ms
  
  ActiveRecord::StatementInvalid - PG::UndefinedFunction: ERROR:  operator does not exist: text ~~* integer
  LINE 1: ...edger_id" = 2 AND (to_char(invoice_no, '9999999') ILIKE 0) O...
                                                               ^
  HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
  : SELECT  "invoices".* FROM "invoices"  WHERE "invoices"."ledger_id" = 2 AND (to_char(invoice_no, '9999999') ILIKE 0) ORDER BY invoice_no desc LIMIT 10 OFFSET 0:
    activerecord (3.2.17) lib/active_record/connection_adapters/abstract_adapter.rb:285:in `rescue in log'
    activerecord (3.2.17) lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log'
    activerecord (3.2.17) lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `exec_query'
    activerecord (3.2.17) lib/active_record/connection_adapters/postgresql_adapter.rb:1262:in `select'
    activerecord (3.2.17) lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    activerecord (3.2.17) lib/active_record/connection_adapters/abstract/query_cache.rb:61:in `block in select_all'
    activerecord (3.2.17) lib/active_record/connection_adapters/abstract/query_cache.rb:75:in `cache_sql'
    activerecord (3.2.17) lib/active_record/connection_adapters/abstract/query_cache.rb:61:in `select_all'
    activerecord (3.2.17) lib/active_record/querying.rb:38:in `block in find_by_sql'
  </code></pre>
  
  <p><strong>Update</strong>  </p>
  
  <p>I'm using invoice_no_cont in an AngularJS view, like so.</p>
  
  <pre><code>&lt;td data-title="'Invoice No.'" sortable="'invoice_no'" filter="{'invoice_no_cont':'text'}"&gt;
        {{invoice.invoice_no}}
  &lt;/td&gt;
  </code></pre>
  
  <p>This is passed through a 'GET' request to the Ruby on Rails server invoice#index method which then picks it up and sends it through ransack.</p>
  
  <pre><code> @invoices = Invoice.search(params[:filter]).result
  </code></pre>