Ruby on Rails: What did you name the routes prefix?

I want to create a link that has a prefix attached to the named route itself. Something like this to display the path "/ old / recipes":

recipes_path(:prefix => "old/")  # the correct way should show "/old/recipes"

I do not want to touch the route.rb file, but I am changing the named route with the prefix attached. Is this possible and how do you do it right?

EDIT: I am using Rails 3. The reason for adding an additional prefix is ​​because I want to use the regular recipes_path. So I want to use "/ recipes" and "/ old / recipes".

+5
source share
1 answer

, , , Rails , , . , config/routes.rb, :

scope :path => "old" do
  resources :recipes
end

, recipes_path, /old/recipes, , . as scope:

scope :path => "old", :as => "old" do
  resources :recipes
end

old_recipes_path, /old/recipes.

+11

All Articles