title: Custom URL in Rails route
body: <p>I wanna add a suffix to my URL according to the <code>type</code> column in my database table.</p>
  
  <pre><code># shop_controller.rb
  ...
  def near
    @shop = Shop.find(params[:id])
    @type = @shop.type
  end
  
  # routes.rb
  resources :spots do
    member do
      get :near
    end
  end
  </code></pre>
  
  <p>Pages I have is currently in <code>app/views/shops/nearby.html.erb</code>. The url that is produced is currently:</p>
  
  <pre><code>http://localhost/shops/1/near
  </code></pre>
  
  <p>Instead of creating multiple pages for different types: <code>nearby_country.html.erb</code>, <code>nearby_state.html.erb</code>, <code>nearby_city.html.erb</code> which is not RESTful, I would prefer to append the type on this url to filter the shops by type, so that in future when I have more types it can automatically be shown:</p>
  
  <pre><code>http://localhost/shops/1/near_country
  http://localhost/shops/1/near_state
  http://localhost/shops/1/near_city
  </code></pre>
  
  <p>I also wanna be able to do the custom path for my menu like:</p>
  
  <pre><code>nearby_country_shop_path
  nearby_state_shop_path
  nearby_city_shop_path
  </code></pre>
  
  <p>Can anyone gimme some hints? Thanks!</p>