From 1ac7cd56fe4b49f0d30c96b2ec68abde8b05ee18 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 18 May 2007 00:36:14 +0000 Subject: Clean up the simply_helpful merge. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6751 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/base.rb | 3 +-- .../lib/action_controller/polymorphic_routes.rb | 30 ++++++++++------------ 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 7afacd4f69..a10ac44939 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -560,7 +560,7 @@ module ActionController #:nodoc: when Hash @url.rewrite(rewrite_options(options)) else - polymorphic_url(options, self) + polymorphic_url(options) end end @@ -1034,7 +1034,6 @@ module ActionController #:nodoc: else redirect_to(url_for(options)) - response.redirected_to = options end end diff --git a/actionpack/lib/action_controller/polymorphic_routes.rb b/actionpack/lib/action_controller/polymorphic_routes.rb index 88bd7ab192..c60b533205 100644 --- a/actionpack/lib/action_controller/polymorphic_routes.rb +++ b/actionpack/lib/action_controller/polymorphic_routes.rb @@ -1,40 +1,38 @@ module ActionController module PolymorphicRoutes - extend self - - def polymorphic_url(record_or_hash, url_writer, options = {}) + def polymorphic_url(record_or_hash, options = {}) record = extract_record(record_or_hash) case when options[:action] == "new" - url_writer.send( + send( action_prefix(options) + RecordIdentifier.singular_class_name(record) + routing_type(options) ) when record.respond_to?(:new_record?) && record.new_record? - url_writer.send( + send( action_prefix(options) + RecordIdentifier.plural_class_name(record) + routing_type(options) ) else - url_writer.send( + send( action_prefix(options) + RecordIdentifier.singular_class_name(record) + routing_type(options), record_or_hash ) end end - def polymorphic_path(record_or_hash, url_writer) - polymorphic_url(record_or_hash, url_writer, :routing_type => :path) + def polymorphic_path(record_or_hash) + polymorphic_url(record_or_hash, :routing_type => :path) end %w( edit new formatted ).each do |action| - module_eval <<-EOT - def #{action}_polymorphic_url(record_or_hash, url_writer) - polymorphic_url(record_or_hash, url_writer, :action => "#{action}") + module_eval <<-EOT, __FILE__, __LINE__ + def #{action}_polymorphic_url(record_or_hash) + polymorphic_url(record_or_hash, :action => "#{action}") end - def #{action}_polymorphic_path(record_or_hash, url_writer) - polymorphic_url(record_or_hash, url_writer, :action => "#{action}", :routing_type => :path) + def #{action}_polymorphic_path(record_or_hash) + polymorphic_url(record_or_hash, :action => "#{action}", :routing_type => :path) end EOT end @@ -44,13 +42,13 @@ module ActionController def action_prefix(options) options[:action] ? "#{options[:action]}_" : "" end - + def routing_type(options) "_#{options[:routing_type] || "url"}" end - + def extract_record(record_or_hash) record_or_hash.is_a?(Hash) ? record_or_hash[:id] : record_or_hash end end -end \ No newline at end of file +end -- cgit v1.2.3