Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

No way to set a global path_name in Routes

#4312

In Rails 2.3, we could rename path names of our choosing globally in a configuration file. This isn't available in Rails 3.

config.action_controller.resources_path_names = { :new => 'make', :edit => 'change' }

Reported by Rizwan Reza · April 2nd, 2010 @ 12:27 PM

State: resolved
Milestone: 3.0.2
Assigned to: Rizwan Reza Rizwan Reza
Importance: Low

Activity

  1. Andrew White
    Andrew White

    I've been looking at this today and I don't think it's a good idea to be putting it back in. You can override using a scope and it keeps the configuration all in one place. Also adding a global config would override resources defined in engines and plugins resulting in hard to track down bugs.

    Ideally we'd give application routes precedence over plugin/engine routes (#2592), then to localize routes you'd do something like the following:

    
      # my_plugin/config/routes.rb
      Rails.application.routes.draw do |map|
        resources :categories do
          resources :products
        end
      end
    
      # my_application/config/routes.rb
      MyApplication::Application.routes.draw do |map|
        scope(:resources_path_names => { :new => "neu", :edit => "bearbeiten" }) do
          resources :categories, :path => "kategorien" do
            resources :products, :path => "produkte"
          end
        end
      end
    

    Okay, you'd end up redefining all of the plugin's routes but that's not an onerous task and would probably have to be done anyway to customize the resource path names. Alternatively maybe they'd be better off as I18n keys in the current locale since that's the primary purpose of this feature.

    April 4th, 2010 @ 04:10 PM

  2. Rizwan Reza
    Rizwan Reza
    • State changed from open to resolved

    April 5th, 2010 @ 04:09 PM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM