title: Add a common route for multiple resources
body: <p>How do I add the <code>/search</code> endpoint to all these resources in one go?</p>
  
  <pre><code>MyCoolApp::Application.routes.draw do
  
    resources :posts, only [:index, :show, :create] do
      collection { get :search }
    end
  
    resources :authors, only [:index, :show] do
      collection { get :search }
    end
  
    resources :comments, only: [:index, :show] do
      collection { get :search }
    end
  
    resources :categories, only: [:index, :show] do
      collection { get :search }
    end
  
    resources :tags, only: [:index] do
      collection { get :search }
    end
  end
  </code></pre>
  
  <p>I saw <a href="https://stackoverflow.com/a/5247045/986415">this answer</a> which is close, but I need to be able to specify the actions for reach resource. Is there a better way to inject the search route in a better way?</p>
  
  <pre><code>%w(one two three four etc).each do |r|
    resources r do
      collection do
        post 'common_action'
      end
    end
  end
  </code></pre>
  
  <p>Something like this?</p>
  
  <pre><code>resources :posts, only [:index, :show, :create, :search]
  </code></pre>