Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 58d3b9042302d41f90fc129f12787d83f7bdade9 1 parent c05f24c
Yehuda Katz wycats authored

Showing 1 changed file with 8 additions and 6 deletions. Show diff stats Hide diff stats

  1. +8 6 actionpack/lib/action_view/helpers/form_helper.rb
14 actionpack/lib/action_view/helpers/form_helper.rb
@@ -519,16 +519,18 @@ def apply_form_for_options!(object_or_array, options) #:nodoc:
519 519 # Delete: <%= project_fields.check_box :_destroy %>
520 520 # <% end %>
521 521 # <% end %>
522   - def fields_for(record_or_name_or_array, *args, &block)
  522 + def fields_for(record, record_object = nil, options = nil, &block)
523 523 raise ArgumentError, "Missing block" unless block_given?
524   - options = args.extract_options!
525 524
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
527 529 when String, Symbol
528   - object_name = record_or_name_or_array
529   - object = args.first
  530 + object = record_object
  531 + object_name = record
530 532 else
531   - object = record_or_name_or_array
  533 + object = record
532 534 object_name = ActiveModel::Naming.singular(object)
533 535 end
534 536

1 comment on commit 58d3b90

Akira Matsuda
Collaborator

at asakusa.rb :)

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