title: Rails' Ransack Search with check_box for an associated model
body: <p>I got lost when I use 'ransack', a Rails Serching gem.</p>
  
  <p>What I want to do is to work check-boxes for an asociated model.</p>
  
  <p>Here is my code.</p>
  
  <p>shows_controller.rb</p>
  
  <pre><code>class ShowsController &lt; ApplicationController
  def index
      @q = Show.search(params[:q])
      @shows = @q.result(:distinct =&gt; true)
      @shows = @shows.joins(:tickets)
  
      respond_to do |format|
        format.html # index.html.erb                                                                                                       
        format.json { render json: @shows }
      end
  end
  </code></pre>
  
  <p>index.html.erb</p>
  
  <pre><code>&lt;%= search_form_for @q do |f| %&gt;
    &lt;%= f.label "Show's Title: " %&gt;
    &lt;%= f.search_field :title_cont %&gt;
    &lt;%= f.label "Buy at:" %&gt;
    &lt;%= check_box_tag 'q[shows_tickets_store_cont[]]', 'venue' %&gt;At Venue
    &lt;%= check_box_tag 'q[shows_tickets_store_cont[]]', 'ticketmaster' %&gt;Ticketmaster
    &lt;%= submit_tag "Find Now" %&gt;
  &lt;% end %&gt;
  
  &lt;% @shows.each do |show| %&gt;
    &lt;%= show.title %&gt; | 
    &lt;% show.tickets.each do |ticket| %&gt;
      &lt;%= ticket.store %&gt;&lt;br /&gt;
    &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>show.rb</p>
  
  <pre><code>class Show &lt; ActiveRecord::Base
    has_many :tickets
  end
  </code></pre>
  
  <p>ticket.rb</p>
  
  <pre><code>class Ticket &lt; ActiveRecord::Base
    belongs_to :show
  end
  </code></pre>
  
  <p>When I wrote something in the search_field, checked the "check_box" and clicked "Find Now" button, the log showed like below;</p>
  
  <pre><code>Parameters: {"utf8"=&gt;"✓", "q"=&gt;{"title_cont"=&gt;"something", "shows_tickets_store_cont"=&gt;"venue"}, "commit"=&gt;"Find Now"}
  Show Load (1.1ms)  SELECT DISTINCT `shows`.* FROM `shows` INNER JOIN `tickets` ON `tickets`.`show_id` = `shows`.`id` WHERE (`shows`.`title` LIKE '%something%') LIMIT 25 OFFSET 0
  </code></pre>
  
  <p>I have no idea why the SQL doesn't have <code>WHERE</code> clause for Ticket.store, in spite of ticket controller received "shows_tickets_title_cont"=>"venue".</p>
  
  <p>Please, suggest solution for this.</p>
  
  <p>Thanks in Advance.</p>