Skip to content

Commit

Permalink
avoid calling extract_record multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Apr 30, 2014
1 parent f1c0358 commit 8761557
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
Expand Up @@ -132,7 +132,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
end

args.delete_if {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
named_route = build_named_route_call(record_or_hash_or_array, inflection, options)
named_route = build_named_route_call(record_or_hash_or_array, record, inflection, options)

url_options = options.except(:action, :routing_type)
unless url_options.empty?
Expand Down Expand Up @@ -175,7 +175,7 @@ def routing_type(options)
options[:routing_type] || :url
end

def build_named_route_call(records, inflection, options = {})
def build_named_route_call(records, record, inflection, options = {})
if records.is_a?(Array)
record = records.pop
route = records.map do |parent|
Expand All @@ -186,7 +186,6 @@ def build_named_route_call(records, inflection, options = {})
end
end
else
record = extract_record(records)
route = []
end

Expand Down

0 comments on commit 8761557

Please sign in to comment.