0
@@ -48,6 +48,9 @@ module ActionController
0
# # calls post_url(post)
0
# polymorphic_url(post) # => "http://example.com/posts/1"
0
+ # polymorphic_url([blog, post]) # => "http://example.com/blogs/1/posts/1"
0
+ # polymorphic_url([:admin, blog, post]) # => "http://example.com/admin/blogs/1/posts/1"
0
+ # polymorphic_url([user, :blog, post]) # => "http://example.com/users/1/blog/posts/1"
0
@@ -83,8 +86,6 @@ module ActionController
0
else [ record_or_hash_or_array ]
0
- args << format if format
0
when options[:action].to_s == "new"
0
@@ -96,6 +97,9 @@ module ActionController
0
+ args.delete_if {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
0
+ args << format if format
0
named_route = build_named_route_call(record_or_hash_or_array, namespace, inflection, options)
0
send!(named_route, *args)
0
@@ -136,11 +140,19 @@ module ActionController
0
route = records.inject("") do |string, parent|
0
- string << "#{RecordIdentifier.send!("singular_class_name", parent)}_"
0
+ if parent.is_a?(Symbol) || parent.is_a?(String)
0
+ string << "#{parent}_"
0
+ string << "#{RecordIdentifier.send!("singular_class_name", parent)}_"
0
- route << "#{RecordIdentifier.send!("#{inflection}_class_name", record)}_"
0
+ if record.is_a?(Symbol) || record.is_a?(String)
0
+ route << "#{RecordIdentifier.send!("#{inflection}_class_name", record)}_"
0
action_prefix(options) + namespace + route + routing_type(options).to_s
0
@@ -163,16 +175,17 @@ module ActionController
0
+ # Remove the first symbols from the array and return the url prefix
0
+ # implied by those symbols.
0
def extract_namespace(record_or_hash_or_array)
0
- returning "" do |namespace|
0
- if record_or_hash_or_array.is_a?(Array)
0
- record_or_hash_or_array.delete_if do |record_or_namespace|
0
- if record_or_namespace.is_a?(String) || record_or_namespace.is_a?(Symbol)
0
- namespace << "#{record_or_namespace}_"
0
+ return "" unless record_or_hash_or_array.is_a?(Array)
0
+ while (key = record_or_hash_or_array.first) && key.is_a?(String) || key.is_a?(Symbol)
0
+ namespace_keys << record_or_hash_or_array.shift
0
+ namespace_keys.map {|k| "#{k}_"}.join