title: creating an dropdown menu with form_tag and pass the selected field to a route
body: <p>Hiho,</p>
  
  <p>I am currently programming a shift planer and encountered a problem with my checkbox.</p>
  
  <p>I had a checkbox to select the department I wanted to show.
  It looked like this:</p>
  
  <pre><code>&lt;%= form_tag("planers", method: :get) do %&gt;
  
  &lt;%= select_tag "department", options_from_collection_for_select(@departments, "id", "name")%&gt;
  
  &lt;%= submit_tag "go", name: nil, class: 'btn' %&gt;
  </code></pre>
  
  
  
  <p>and this worked perfectly fine. but it created ugly URL. </p>
  
  <p>e.g. localhost:3000/planers?utf8=✓&amp;department=1</p>
  
  <p>But I wanted to change my URL to something like this. localhost:3000/1 for the department with ID 1. That was the easy part.</p>
  
  <p>I changed this to my routes.rb </p>
  
  <pre><code>get ':department(/:week)' =&gt; 'planers#index', as: :week_planer
  </code></pre>
  
  <p>I take 1 parameter for the department and one optional one for the week that schould be displayed.</p>
  
  <p>I adjusted my button that shows the next week to this</p>
  
  <pre><code>&lt;%= link_to "prev", week_planer_path(department: params['department'],week: @week+1) , class: 'btn btn-default' %&gt;
  </code></pre>
  
  <p>this also works perfectly fine. The big question is:</p>
  
  <p><strong>how do I adjust my form_tag in a way that it calls a defined route with the selected field as a param?</strong></p>
  
  <p>I definately want to use get, because every department schould have a direct link to their shift planer. 
  (I guess in case this can only be done with post I could define the same route as post and get and give it different path names so localhost:3000/1 still works)</p>
  
  <pre><code>&lt;%= form_tag week_planer_path([:department]), method: :get do %&gt;
    &lt;%= select_tag "department", options_from_collection_for_select(@departments, "id", "name")%&gt;
    &lt;%= submit_tag "go", name: nil, class: 'btn' %&gt;
   &lt;% end %&gt;
  </code></pre>
  
  <p>but it produces something like this:</p>
  
  <p><a href="http://localhost:3000/department?utf8=%E2%9C%93&amp;department=1" rel="nofollow">http://localhost:3000/department?utf8=%E2%9C%93&amp;department=1</a></p>
  
  <p>I spend like 6h+ on researching on this but i couldnt come up with a solution. I hope someone knows a solution, if possible w/o js.</p>
  
  <p>if someone wants to take a look on my repo, here u go:</p>
  
  <p><a href="https://github.com/Elux91/shift-planer" rel="nofollow">https://github.com/Elux91/shift-planer</a></p>