aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-04-02 19:13:47 +0200
committerJosé Valim <jose.valim@gmail.com>2010-04-02 19:13:47 +0200
commita0cdb0499eecd40ba18d33226767783e4a058847 (patch)
tree4ba13c5ba2dd4b1dfc8ee7a8e62c671812f80825 /actionpack/lib/action_dispatch/routing
parent3adaef8ae73a3061a9fe4c5e0256d80bc09b1cf4 (diff)
downloadrails-a0cdb0499eecd40ba18d33226767783e4a058847.tar.gz
rails-a0cdb0499eecd40ba18d33226767783e4a058847.tar.bz2
rails-a0cdb0499eecd40ba18d33226767783e4a058847.zip
Maintain the usage of :as consistent in the router. Whenever it's supplied, it changes the NAMED ROUTE. If you want to change the PATH, use :path instead. Example: resources :projects, :path => 'projetos'
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb53
1 files changed, 28 insertions, 25 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 8a84afd315..4e9112bc04 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -194,6 +194,21 @@ module ActionDispatch
self
end
+ def mount(app, options = nil)
+ if options
+ path = options.delete(:at)
+ else
+ options = app
+ app, path = options.find { |k, v| k.respond_to?(:call) }
+ options.delete(app) if app
+ end
+
+ raise "A rack application must be specified" unless path
+
+ match(path, options.merge(:to => app, :anchor => false))
+ self
+ end
+
def default_url_options=(options)
@set.default_url_options = options
end
@@ -380,14 +395,13 @@ module ActionDispatch
[:index, :create, :new, :show, :update, :destroy, :edit]
end
- attr_reader :plural, :singular, :options
+ attr_reader :controller, :path, :options
def initialize(entities, options = {})
- @name = entities.to_s
- @options = options
-
- @plural = @name.pluralize
- @singular = @name.singularize
+ @name = entities.to_s
+ @path = options.delete(:path) || @name
+ @controller = options.delete(:controller) || @name.to_s.pluralize
+ @options = options
end
def default_actions
@@ -417,8 +431,12 @@ module ActionDispatch
options[:as] || @name
end
- def controller
- options[:controller] || plural
+ def plural
+ name.to_s.pluralize
+ end
+
+ def singular
+ name.to_s.singularize
end
def member_name
@@ -509,7 +527,7 @@ module ActionDispatch
resource = SingletonResource.new(resources.pop, options)
- scope(:path => resource.name.to_s, :controller => resource.controller) do
+ scope(:path => resource.path, :controller => resource.controller) do
with_scope_level(:resource, resource) do
scope(:name_prefix => resource.name.to_s, :as => "") do
@@ -539,7 +557,7 @@ module ActionDispatch
resource = Resource.new(resources.pop, options)
- scope(:path => resource.name.to_s, :controller => resource.controller) do
+ scope(:path => resource.path, :controller => resource.controller) do
with_scope_level(:resources, resource) do
yield if block_given?
@@ -603,21 +621,6 @@ module ActionDispatch
end
end
- def mount(app, options = nil)
- if options
- path = options.delete(:at)
- else
- options = app
- app, path = options.find { |k, v| k.respond_to?(:call) }
- options.delete(app) if app
- end
-
- raise "A rack application must be specified" unless path
-
- match(path, options.merge(:to => app, :anchor => false))
- self
- end
-
def match(*args)
options = args.extract_options!