diff options
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 21 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 |
3 files changed, 10 insertions, 16 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 1733c8032a..f67708722b 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -107,7 +107,7 @@ module ActionDispatch if @options[:format] == false @options.delete(:format) path - elsif path.include?(":format") + elsif path.include?(":format") || path.end_with?('/') path else "#{path}(.:format)" @@ -243,10 +243,6 @@ module ActionDispatch end module Base - def initialize(set) #:nodoc: - @set = set - end - # You can specify what Rails should route "/" to with the root method: # # root :to => 'pages#main' @@ -558,11 +554,6 @@ module ActionDispatch # PUT /admin/posts/1 # DELETE /admin/posts/1 module Scoping - def initialize(*args) #:nodoc: - @scope = {} - super - end - # Scopes a set of routes to the given default options. # # Take the following route definition as an example: @@ -956,11 +947,6 @@ module ActionDispatch alias :nested_scope :path end - def initialize(*args) #:nodoc: - super - @scope[:path_names] = @set.resources_path_names - end - def resources_path_names(options) @scope[:path_names].merge!(options) end @@ -1473,6 +1459,11 @@ module ActionDispatch end end + def initialize(set) #:nodoc: + @set = set + @scope = { :path_names => @set.resources_path_names } + end + include Base include HttpHelpers include Redirection diff --git a/actionpack/lib/action_dispatch/routing/route.rb b/actionpack/lib/action_dispatch/routing/route.rb index 08a8408f25..eae9d4ea6d 100644 --- a/actionpack/lib/action_dispatch/routing/route.rb +++ b/actionpack/lib/action_dispatch/routing/route.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/module/deprecation' + module ActionDispatch module Routing class Route #:nodoc: @@ -45,6 +47,7 @@ module ActionDispatch def to_a [@app, @conditions, @defaults, @name] end + deprecate :to_a def to_s @to_s ||= begin diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 61053d4464..b28f6c2297 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -333,7 +333,7 @@ module ActionDispatch def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true) raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i) route = Route.new(self, app, conditions, requirements, defaults, name, anchor) - @set.add_route(*route) + @set.add_route(route.app, route.conditions, route.defaults, route.name) named_routes[name] = route if name routes << route route |