aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-06-07 21:35:01 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-06-07 21:35:01 +0000
commitc7df5bd6ac256cf75631f8c59c1de1f96df02b17 (patch)
tree540eb0ff609ddbec455e24002ee2b78e79e123ff /actionpack/lib
parent5600776e309b9c84f0cc075391b6130d07d83cfd (diff)
downloadrails-c7df5bd6ac256cf75631f8c59c1de1f96df02b17.tar.gz
rails-c7df5bd6ac256cf75631f8c59c1de1f96df02b17.tar.bz2
rails-c7df5bd6ac256cf75631f8c59c1de1f96df02b17.zip
More nested polymorphic url helper fixes. Closes #6432, references #8601.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6960 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/polymorphic_routes.rb13
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb3
2 files changed, 11 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/polymorphic_routes.rb b/actionpack/lib/action_controller/polymorphic_routes.rb
index 6c21bc27c5..d6c57d1207 100644
--- a/actionpack/lib/action_controller/polymorphic_routes.rb
+++ b/actionpack/lib/action_controller/polymorphic_routes.rb
@@ -3,7 +3,14 @@ module ActionController
def polymorphic_url(record_or_hash_or_array, options = {})
record = extract_record(record_or_hash_or_array)
- args = []
+ args = case record_or_hash_or_array
+ when Hash: [record_or_hash_or_array[:id]]
+ when Array: record_or_hash_or_array.dup
+ else [record_or_hash_or_array]
+ end
+
+ args.pop # Remove the base record; we only need it in one case
+
inflection =
case
when options[:action] == "new"
@@ -11,10 +18,10 @@ module ActionController
when record.respond_to?(:new_record?) && record.new_record?
:plural
else
- args = [record_or_hash_or_array]
+ args.push(record) # Put the base record back in
:singular
end
-
+
named_route = build_named_route_call(record_or_hash_or_array, inflection, options)
send(named_route, *args)
end
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 1886c7ab15..b003b69bb1 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -166,13 +166,12 @@ module ActionView
when Array
object = record_or_name_or_array.last
object_name = ActionController::RecordIdentifier.singular_class_name(object)
- # apply_form_for_options!(object, options, *record_or_name_or_array)
apply_form_for_options!(record_or_name_or_array, options)
args.unshift object
else
object = record_or_name_or_array
object_name = ActionController::RecordIdentifier.singular_class_name(object)
- apply_form_for_options!([ object ], options)
+ apply_form_for_options!([object], options)
args.unshift object
end