title: How can I create custom route helpers for usage in routes.rb
body: <p>I have a few reoccurring patterns in my routes.rb and I would like to make it DRY by creating a method that creates those routes for me.</p>
  
  <p>An example of what I want to accomplish can be seen in the Devise gem where you can use the following syntax:</p>
  
  <pre><code>#routes.rb
  devise_for :users
  </code></pre>
  
  <p>Which will generate all the routes necessary for Devise. I would like to create something similar. Say for example that I have the following routes:</p>
  
  <pre><code>resources :posts do
    member do
      get 'new_file'
      post 'add_file'
    end
    match 'files/:id' =&gt; 'posts#destroy_file', :via =&gt; :delete, :as =&gt; :destroy_file
  end
  
  resources :articles do
    member do
      get 'new_file'
      post 'add_file'
    end
    match 'files/:id' =&gt; 'articles#destroy_file', :via =&gt; :delete, :as =&gt; :destroy_file
  end
  </code></pre>
  
  <p>This starts getting messy quite quickly so I would like to find a way to do it like this instead:</p>
  
  <pre><code>resources_with_files :posts
  resources_with_files :articles
  </code></pre>
  
  <p>So my question is, how can I create the resources_with_files method?</p>