Skip to content
Browse files

Speed up form_for by specializing extract_options! (at asakusa.rb)

  • Loading branch information...
1 parent c05f24c commit 58d3b9042302d41f90fc129f12787d83f7bdade9 @wycats wycats committed Aug 31, 2010
Showing with 8 additions and 6 deletions.
  1. +8 −6 actionpack/lib/action_view/helpers/form_helper.rb
View
14 actionpack/lib/action_view/helpers/form_helper.rb
@@ -519,16 +519,18 @@ def apply_form_for_options!(object_or_array, options) #:nodoc:
# Delete: <%= project_fields.check_box :_destroy %>
# <% end %>
# <% end %>
- def fields_for(record_or_name_or_array, *args, &block)
+ def fields_for(record, record_object = nil, options = nil, &block)
raise ArgumentError, "Missing block" unless block_given?
- options = args.extract_options!
- case record_or_name_or_array
+ options, record_object = record_object, nil if record_object.is_a?(Hash)
+ options ||= {}
+
+ case record
when String, Symbol
- object_name = record_or_name_or_array
- object = args.first
+ object = record_object
+ object_name = record
else
- object = record_or_name_or_array
+ object = record
object_name = ActiveModel::Naming.singular(object)
end

1 comment on commit 58d3b90

@amatsuda
Ruby on Rails member

at asakusa.rb :)

Please sign in to comment.
Something went wrong with that request. Please try again.