Skip to content

Commit 58d3b90

Browse files
committed
Speed up form_for by specializing extract_options! (at asakusa.rb)
1 parent c05f24c commit 58d3b90

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

actionpack/lib/action_view/helpers/form_helper.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,16 +519,18 @@ def apply_form_for_options!(object_or_array, options) #:nodoc:
519519
# Delete: <%= project_fields.check_box :_destroy %>
520520
# <% end %>
521521
# <% end %>
522-
def fields_for(record_or_name_or_array, *args, &block)
522+
def fields_for(record, record_object = nil, options = nil, &block)
523523
raise ArgumentError, "Missing block" unless block_given?
524-
options = args.extract_options!
525524

526-
case record_or_name_or_array
525+
options, record_object = record_object, nil if record_object.is_a?(Hash)
526+
options ||= {}
527+
528+
case record
527529
when String, Symbol
528-
object_name = record_or_name_or_array
529-
object = args.first
530+
object = record_object
531+
object_name = record
530532
else
531-
object = record_or_name_or_array
533+
object = record
532534
object_name = ActiveModel::Naming.singular(object)
533535
end
534536

0 commit comments

Comments
 (0)