title: RoR search using dropdowns and checkboxes
body: <p>This should be relatively simple, and I'm probably overthinking this, but I can't figure it out. Time to call S.O. in for help. First, the bulleted list of what I'm trying to accomplish, then the code.</p>
  
  <ul>
  <li>I have 8 DB tables, 1 "venue", 7 "days of the week" (Monday, Tues, etc)</li>
  <li>Individual "venues" have an "area" column, as well as a ton of other columns</li>
  <li>I have 3 dropdown menus, the first of which is used to select an "area", the second to select a "day of the week", the third to select an "hour" on the "day of the week" table.</li>
  <li>There are also several checkboxes I'm using to return all results which match whatever is checked (I've got this part figured out, basically, since all the data is within the "venue" table).</li>
  <li>These dropdowns and checkboxes are within a form in application.html.erb</li>
  <li>Ideally, a user should be able to select ONLY an area, and return all results, and leave the other dropdowns blank, OR select ONLY a day of the week, and leave the others blank, etc</li>
  <li>All results should list on venues#index</li>
  </ul>
  
  <p>Alright, now time for the disaster - the code.</p>
  
  <p>venue controller</p>
  
  <pre><code>def index
    case 
    when params[:area]
      @venues = Venue.where(:area =&gt; params[:area])
    when params[:day]
      @venues = Venue.where(:day =&gt; params[:day])
    end
  end  
  </code></pre>
  
  <p>application.html.erb</p>
  
  <pre><code>&lt;%= form_tag(venues_path, :method=&gt;:get, id: "search-form") do |f| %&gt;
      &lt;div class="col span_1_of_3"&gt;
      &lt;%= select_tag "area", options_for_select([ " ", "Area 1", "Area 2" ], params[:area]), {:class=&gt;"styled-select"} %&gt;
      &lt;/div&gt;
      &lt;div class="col span_1_of_3"&gt;
          &lt;%= select_tag "day", options_for_select([ " ", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], params[:day]), {:class=&gt;"styled-select"} %&gt;
      &lt;/div&gt; 
      &lt;div class="col span_1_of_3"&gt;
      &lt;%= select_tag "day", options_for_select([[" ", " "], ["3pm", "t1500"], ["4pm", "t1600"], ["5pm", "t1700"], ["6pm", "t1800"], ["7pm", "t1900"], ["8pm", "t2000"], ["9pm", "t2100"], ["10pm", "t2200"], ["11pm", "t2300"], ["12am", "t0000"], ["1am", "t0100"], ["2am", "t0200"], ["3am", "t0300"], ["4am", "t0400"], ["5am", "t0500"], ["6am", "t0600"], ["7am", "t0700"], ["8am", "t0800"], ["9am", "t0900"], ["10am", "t1000"], ["11am", "t1100"], ["12pm", "t1200"], ["1pm", "t1300"], ["2pm", "t1400"]]), {:class=&gt;"styled-select", id: "t", name: "t"} %&gt;
      &lt;/div&gt;
      &lt;br&gt;
      &lt;button data-style="expand-right" data-size="s" type=submit class="button"&gt;Submit&lt;/button&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>venue model (omitted since I haven't really modified it other than adding nested attributes for new venues - which are working). I'll post it if I need to.</p>
  
  <p>So like I said, I've been racking my brain on this and I can't figure out how to build the correct query/filter to get the results. Am I just approaching this all wrong?</p>