title: Filter collection with select dropdown in Rails with Ransack
body: <p>I am new to Ransack and I am pretty confused to get to the result I want. If anybody can shed a light I'll be grateful.
  I am trying to create a filter by "City" for the ship_projects collection in the view statistics/index and I am using Ransack.</p>
  
  <p>The models <code>ShipProjects</code> and <code>Cities</code> are far apart with many relations.</p>
  
  <p><strong>ship_projects</strong> &lt; has_many <strong>ship_groups</strong> &lt; has_many <strong>shipments</strong> > belongs_to <strong>people</strong></p>
  
  <p><strong>people</strong> &lt; has_many <strong>postal_addresses</strong> > belongs_to <strong>cities</strong></p>
  
  <p><strong>Models</strong></p>
  
  <pre><code>class ShipProject &lt; ActiveRecord::Base
    has_many :ship_groups
    has_many :shipments, through: :ship_groups
  
  class ShipGroup &lt; ActiveRecord::Base
    belongs_to :ship_project
    has_many :shipments
  
  class Shipment &lt; ActiveRecord::Base
    belongs_to :person
    belongs_to :ship_group
  
  class Person &lt; ActiveRecord::Base
    has_many :postal_addresses
    has_many :cities, through: :postal_addresses
  
  class PostalAddress &lt; ActiveRecord::Base
    belongs_to :person
    belongs_to :city
  
  class City &lt; ActiveRecord::Base
    has_many :postal_addresses
  </code></pre>
  
  <p><strong>Statistics Controller</strong></p>
  
  <pre><code>  def index
      @q = ShipProject.ransack(params[:q])
      @ship_projects = @q.result.includes(:people, :cities)
      respond_to do |format|
        format.html
        format.xlsx { render xlsx: 'index', filename: 'reporte_envios.xlsx' }
      end
    end
  </code></pre>
  
  <p><strong>statistics/index.html.erb</strong></p>
  
  <pre><code>&lt;%= search_form_for @q do |f| %&gt;
    &lt;div class='form-inline form-group'&gt;
      &lt;div class='row'&gt;
        &lt;div class='col-md-4'&gt;
          &lt;%= f.label :city_id_eq, "City" %&gt;&lt;br/&gt;
          &lt;%= f.select :city_id_eq, options_from_collection_for_select(City.all.order(:name), :id, :name, @q.city_id_eq), { }, {class: 'form-control'} %&gt;
        &lt;/div&gt;
        &lt;div class="col-md-4"&gt;
          &lt;%= f.submit "Filter", class: 'btn btn-info btn-block' %&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>In the console I'am getting the following error:</p>
  
  <pre><code>Started GET "/statistics" for ::1 at 2015-08-12 17:51:39 -0500
  Processing by StatisticsController#index as HTML
    User Load (0.3ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 8  ORDER BY `users`.`id` ASC LIMIT 1
    Rendered layouts/_messages.html.erb (0.3ms)
    Rendered statistics/index.html.erb within layouts/application (5.2ms)
  Completed 500 Internal Server Error in 12ms (ActiveRecord: 0.3ms)
  
  NoMethodError - undefined method `city_id_eq' for #&lt;Ransack::Search:0x007fc481bf3478&gt;:
  </code></pre>