aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-05-18 00:36:14 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-05-18 00:36:14 +0000
commit1ac7cd56fe4b49f0d30c96b2ec68abde8b05ee18 (patch)
tree9efe8a7754037e0782c8872f04f3703c6aa10f4f /actionpack/lib
parentebee0a742d40f87bb9b78d5d88393c341761cfad (diff)
downloadrails-1ac7cd56fe4b49f0d30c96b2ec68abde8b05ee18.tar.gz
rails-1ac7cd56fe4b49f0d30c96b2ec68abde8b05ee18.tar.bz2
rails-1ac7cd56fe4b49f0d30c96b2ec68abde8b05ee18.zip
Clean up the simply_helpful merge.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6751 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller/base.rb3
-rw-r--r--actionpack/lib/action_controller/polymorphic_routes.rb30
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb3
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb1
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb2
-rw-r--r--actionpack/lib/action_view/partials.rb33
6 files changed, 43 insertions, 29 deletions
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
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index d307c194d2..c985a22edb 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -167,6 +167,7 @@ module ActionView
object = record_or_name
object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name)
apply_form_for_options!(object, options)
+ args.unshift object
end
concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}), proc.binding)
@@ -184,7 +185,7 @@ module ActionView
options[:html] ||= {}
options[:html].reverse_merge!(html_options)
- options[:url] ||= polymorphic_path(object, self)
+ options[:url] ||= polymorphic_path(object)
end
# Creates a scope around a specific model object like form_for, but doesn't create the form tags themselves. This makes
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 9bf9a71df2..1586a99e4c 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -191,6 +191,7 @@ module ActionView
object = record_or_name
object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name)
apply_form_for_options!(object, options)
+ args.unshift object
end
concat(form_remote_tag(options), proc.binding)
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 2329fb4bc6..d22a1464a0 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -75,7 +75,7 @@ module ActionView
url = @controller.send(:url_for, nil)
else
escape = false
- url = polymorphic_path(options, self)
+ url = polymorphic_path(options)
end
escape ? html_escape(url) : url
diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb
index 3d57574aaf..4d7e276255 100644
--- a/actionpack/lib/action_view/partials.rb
+++ b/actionpack/lib/action_view/partials.rb
@@ -48,19 +48,34 @@ module ActionView
private
# Deprecated, use render :partial
def render_partial(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc:
- path, partial_name = partial_pieces(partial_path)
- object = extracting_object(partial_name, local_assigns, deprecated_local_assigns)
- local_assigns = extract_local_assigns(local_assigns, deprecated_local_assigns)
- local_assigns = local_assigns ? local_assigns.clone : {}
- add_counter_to_local_assigns!(partial_name, local_assigns)
- add_object_to_local_assigns!(partial_name, local_assigns, object)
+ case partial_path
+ when String, Symbol, NilClass
+ path, partial_name = partial_pieces(partial_path)
+ object = extracting_object(partial_name, local_assigns, deprecated_local_assigns)
+ local_assigns = extract_local_assigns(local_assigns, deprecated_local_assigns)
+ local_assigns = local_assigns ? local_assigns.clone : {}
+ add_counter_to_local_assigns!(partial_name, local_assigns)
+ add_object_to_local_assigns!(partial_name, local_assigns, object)
- if logger
- ActionController::Base.benchmark("Rendered #{path}/_#{partial_name}", Logger::DEBUG, false) do
+ if logger
+ ActionController::Base.benchmark("Rendered #{path}/_#{partial_name}", Logger::DEBUG, false) do
+ render("#{path}/_#{partial_name}", local_assigns)
+ end
+ else
render("#{path}/_#{partial_name}", local_assigns)
end
+ when Array
+ if partial_path.any?
+ path = ActionController::RecordIdentifier.partial_path(partial_path.first)
+ collection = partial_path
+ render_partial_collection(path, collection, nil, local_assigns.value)
+ else
+ ""
+ end
else
- render("#{path}/_#{partial_name}", local_assigns)
+ render_partial(
+ ActionController::RecordIdentifier.partial_path(partial_path),
+ local_assigns, deprecated_local_assigns)
end
end