title: undefined local variable or method with form_tag
body: <p>I'm trying to create a simple search form in my Rails application. I get an error with the url path of the form:</p>
  
  <pre><code>&lt;%= form_tag(med_search, :method =&gt; "get", id: "search-form") do %&gt;
              &lt;%= text_field_tag :search, params[:search], placeholder: "Search", class: "form-control" %&gt;
              &lt;%= button_to "Search", class: "btn btn-default" %&gt;
            &lt;% end %&gt;
  </code></pre>
  
  <p>The first line above causes error <code>undefined local variable or method</code>med_search' for #&lt;#:0x007fab2b5afa90>`</p>
  
  <p>The problem is most likely with my routes setup. I created a new controller action called search so I edited my routes.db to look like this:</p>
  
  <pre><code>resources :meds do
    collection do
      get 'search' =&gt; 'meds#search'
    end
  end
    devise_for :users
    #get 'meds/index'
    root to: "meds#index"
    resources :meds, :path =&gt; ''
  end
  </code></pre>
  
  <p>When I do rake routes, I am seeing the path med search so I know the url is valid:</p>
  
  <pre><code>                  Prefix Verb   URI Pattern                    Controller#Action
                med_search GET    /meds/:med_id/search(.:format) meds#search
                      meds GET    /meds(.:format)                meds#index
                           POST   /meds(.:format)                meds#create
                   new_med GET    /meds/new(.:format)            meds#new
                  edit_med GET    /meds/:id/edit(.:format)       meds#edit
                       med GET    /meds/:id(.:format)            meds#show
                           PATCH  /meds/:id(.:format)            meds#update
                           PUT    /meds/:id(.:format)            meds#update
                           DELETE /meds/:id(.:format)            meds#destroy
          new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
              user_session POST   /users/sign_in(.:format)       devise/sessions#create
      destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
             user_password POST   /users/password(.:format)      devise/passwords#create
         new_user_password GET    /users/password/new(.:format)  devise/passwords#new
        edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                           PATCH  /users/password(.:format)      devise/passwords#update
                           PUT    /users/password(.:format)      devise/passwords#update
  cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
         user_registration POST   /users(.:format)               devise/registrations#create
     new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
    edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                           PATCH  /users(.:format)               devise/registrations#update
                           PUT    /users(.:format)               devise/registrations#update
                           DELETE /users(.:format)               devise/registrations#destroy
                      root GET    /                              meds#index
                           GET    /                              meds#index
                           POST   /                              meds#create
                           GET    /new(.:format)                 meds#new
                           GET    /:id/edit(.:format)            meds#edit
                           GET    /:id(.:format)                 meds#show
                           PATCH  /:id(.:format)                 meds#update
                           PUT    /:id(.:format)                 meds#update
                           DELETE /:id(.:format)                 meds#destroy
  </code></pre>
  
  <p>What should I change in the routes to fix this?</p>
  
  <p>Thanks!</p>
  
  <p>EDIT: changed url to med_search_path, get new error: <code>No route matches {:action=&gt;"search", :controller=&gt;"meds"} missing required keys: [:med_id]</code>. Looks like it's related to the route <code>/meds/:med_id/search(.:format)</code> </p>