Browse files

Merge pull request #4439 from rafaelfranca/av-refactor

Do not check if record is an Array twice
  • Loading branch information...
2 parents 3f70c10 + ad70d9d commit eea28652c95a062c3b798e37f32852759a003247 @josevalim josevalim committed Jan 13, 2012
Showing with 3 additions and 4 deletions.
  1. +3 −4 actionpack/lib/action_view/helpers/form_helper.rb
View
7 actionpack/lib/action_view/helpers/form_helper.rb
@@ -365,7 +365,7 @@ def form_for(record, options = {}, &proc)
else
object = record.is_a?(Array) ? record.last : record
object_name = options[:as] || ActiveModel::Naming.param_key(object)
- apply_form_for_options!(record, options)
+ apply_form_for_options!(record, object, options)
end
options[:html][:remote] = options.delete(:remote) if options.has_key?(:remote)
@@ -380,8 +380,7 @@ def form_for(record, options = {}, &proc)
output.safe_concat('</form>')
end
- def apply_form_for_options!(object_or_array, options) #:nodoc:
- object = object_or_array.is_a?(Array) ? object_or_array.last : object_or_array
+ def apply_form_for_options!(record, object, options) #:nodoc:
object = convert_to_model(object)
as = options[:as]
@@ -392,7 +391,7 @@ def apply_form_for_options!(object_or_array, options) #:nodoc:
:method => method
)
- options[:url] ||= polymorphic_path(object_or_array, :format => options.delete(:format))
+ options[:url] ||= polymorphic_path(record, :format => options.delete(:format))
end
private :apply_form_for_options!

0 comments on commit eea2865

Please sign in to comment.