From 68d685056a6a8a6fcb7f922c161d26a54c770213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Thu, 6 Sep 2007 14:28:32 +0000 Subject: Remove deprecated named routes [pixeltrix] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7415 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/base.rb | 8 ++++++-- actionpack/lib/action_controller/resources.rb | 24 +++++++++++------------- actionpack/lib/action_controller/routing.rb | 25 ++++--------------------- 3 files changed, 21 insertions(+), 36 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index e0474ff5b3..81db0ed467 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -310,6 +310,10 @@ module ActionController #:nodoc: # Turn on +ignore_missing_templates+ if you want to unit test actions without making the associated templates. cattr_accessor :ignore_missing_templates + # Controls the resource action separator + @@resource_action_separator = "/" + cattr_accessor :resource_action_separator + # Holds the request object that's primarily used to get environment variables through access like # request.env["REQUEST_URI"]. attr_internal :request @@ -605,11 +609,11 @@ module ActionController #:nodoc: def controller_path self.class.controller_path end - + def session_enabled? request.session_options && request.session_options[:disabled] != false end - + # View load paths for controller. def view_paths self.class.view_paths diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index 8e7dedb86f..384f5f30d7 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -94,6 +94,9 @@ module ActionController "#{name_prefix}#{singular}_" end + def action_separator + @action_separator ||= Base.resource_action_separator + end protected def arrange_actions @@ -431,10 +434,8 @@ module ActionController resource.collection_methods.each do |method, actions| actions.each do |action| action_options = action_options_for(action, resource, method) - - # See http://dev.rubyonrails.org/ticket/8251 - map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.name_prefix}#{action}_#{resource.plural}", "#{resource.path}/#{action}", action_options) - map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "formatted_#{resource.name_prefix}#{action}_#{resource.plural}", "#{resource.path}/#{action}.:format", action_options) + map.named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}", action_options) + map.named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}.:format", action_options) end end end @@ -460,13 +461,11 @@ module ActionController actions.each do |action| action_options = action_options_for(action, resource, method) if action == :new - # See http://dev.rubyonrails.org/ticket/8251 - map.deprecated_named_route("new_#{resource.name_prefix}#{resource.singular}", "#{resource.name_prefix}new_#{resource.singular}", resource.new_path, action_options) - map.deprecated_named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.name_prefix}new_#{resource.singular}", "#{resource.new_path}.:format", action_options) + map.named_route("new_#{resource.name_prefix}#{resource.singular}", resource.new_path, action_options) + map.named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}.:format", action_options) else - # See http://dev.rubyonrails.org/ticket/8251 - map.deprecated_named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.name_prefix}#{action}_new_#{resource.singular}", "#{resource.new_path}/#{action}", action_options) - map.deprecated_named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.name_prefix}#{action}_new_#{resource.singular}", "#{resource.new_path}/#{action}.:format", action_options) + map.named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}", action_options) + map.named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}.:format", action_options) end end end @@ -476,9 +475,8 @@ module ActionController resource.member_methods.each do |method, actions| actions.each do |action| action_options = action_options_for(action, resource, method) - # See http://dev.rubyonrails.org/ticket/8251 - map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.name_prefix}#{action}_#{resource.singular}", "#{resource.member_path}/#{action}", action_options) - map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.name_prefix}#{action}_#{resource.singular}", "#{resource.member_path}/#{action}.:format",action_options) + map.named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action}", action_options) + map.named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action}.:format",action_options) end end diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 2565a6dc3c..4cf9b010ba 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -247,7 +247,7 @@ module ActionController # end # module Routing - SEPARATORS = %w( / . ? ) + SEPARATORS = %w( / ; . , ? ) HTTP_METHODS = [:get, :head, :post, :put, :delete] @@ -548,7 +548,7 @@ module ActionController end class Segment #:nodoc: - RESERVED_PCHAR = ':@&=+$,;' + RESERVED_PCHAR = ':@&=+$' UNSAFE_PCHAR = Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}#{RESERVED_PCHAR}]", false, 'N').freeze attr_accessor :is_optional @@ -561,7 +561,7 @@ module ActionController def extraction_code nil end - + # Continue generating string for the prior segments. def continue_string_structure(prior_segments) if prior_segments.empty? @@ -1020,11 +1020,6 @@ module ActionController @set.add_named_route(name, path, options) end - def deprecated_named_route(name, deprecated_name, path, options = {}) - named_route(name, path, options) - @set.add_deprecated_named_route(name, deprecated_name, path, options) unless deprecated_name == name - end - # Enables the use of resources in a module by setting the name_prefix, path_prefix, and namespace for the model. # Example: # @@ -1057,7 +1052,7 @@ module ActionController class NamedRouteCollection #:nodoc: include Enumerable - attr_reader :routes, :helpers, :deprecated_named_routes + attr_reader :routes, :helpers def initialize clear! @@ -1066,7 +1061,6 @@ module ActionController def clear! @routes = {} @helpers = [] - @deprecated_named_routes = {} @module ||= Module.new @module.instance_methods.each do |selector| @@ -1080,12 +1074,6 @@ module ActionController end def get(name) - if @deprecated_named_routes.has_key?(name.to_sym) - ActiveSupport::Deprecation.warn( - "The named route \"#{name}\" uses a format that has been deprecated. " + - "You should use \"#{@deprecated_named_routes[name]}\" instead", caller - ) - end routes[name.to_sym] end @@ -1259,11 +1247,6 @@ module ActionController named_routes[name.to_sym] = add_route(path, options) end - def add_deprecated_named_route(name, deprecated_name, path, options = {}) - add_named_route(deprecated_name, path, options) - named_routes.deprecated_named_routes[deprecated_name.to_sym] = name - end - def options_as_params(options) # If an explicit :controller was given, always make :action explicit # too, so that action expiry works as expected for things like -- cgit v1.2.3