Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your controller you should be able to do something as simple as:</p> <pre><code>@filtered_venues = Venue.where(:area =&gt; params[:venue][:area], :type =&gt; params[:venue][:type]).all </code></pre> <p>That should give you the filtered results that you want.</p> <p>And then in your view you should be able to use form helpers to create the select elements:</p> <pre><code>select("venue", "area", ['New York', 'London', 'Amsterdam'], {}, { :prompt =&gt; 'Select Area' }) select("venue", "type", ['Pub', 'Outdoor', 'Hall'], {}, { :prompt =&gt; 'Select Type' }) </code></pre> <p>Should output something like:</p> <pre><code> &lt;select name="venue[area]"&gt; &lt;option value=""&gt;Select Area&lt;/option&gt; &lt;option value="New York"&gt;New York&lt;/option&gt; &lt;option value="London"&gt;London&lt;/option&gt; &lt;option value="Amsterdam"&gt;Amsterdam&lt;/option&gt; &lt;/select&gt; &lt;select name="venue[:type]"&gt; &lt;option value=""&gt;Select Type&lt;/option&gt; &lt;option value="Pub"&gt;Pub&lt;/option&gt; &lt;option value="Outdoor"&gt;Outdoor&lt;/option&gt; &lt;option value="Hall"&gt;Hall&lt;/option&gt; &lt;/select&gt; </code></pre> <p>There are a lot of other ways to get the options in there dynamically if you have collections ready for area or type. Check out the following for more information: <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html" rel="nofollow">http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload