title: Rails: Preselect Option from dropdown menu
body: <p>i have a working filter on a table, now i want to preselect one of the filters according to in which team a user is. 
  The code for the filter is the following</p>
  
  <pre><code>&lt;%= form_tag request.path, :method =&gt; 'get' do %&gt;  
      &lt;%= select_tag "filter", options_for_select([ "Alle", "Men", "Women", "Juniors" ],  params[:filter]), class: 'my_filter'%&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Now every User belongs to one of the four groups, in the User DB identified as team_id
  now if i open the page i want to select the according fitler for each user as a default.</p>
  
  <p>Thank you for your help</p>
  
  <p>edit:</p>
  
  <p>working with this js to update the code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function(){
      $('select.my_filter').on('change', function(){
        alert($(this).val())
      $(this).closest('form').submit()
      })
  })
  </code></pre>