diff options
author | wycats <wycats@gmail.com> | 2010-08-31 20:33:28 +0900 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-08-31 20:33:28 +0900 |
commit | 58d3b9042302d41f90fc129f12787d83f7bdade9 (patch) | |
tree | 62741ee073f57b7a14806acdf3ac1361609f2c02 /actionpack/lib/action_view/helpers | |
parent | c05f24c824ce9ee855f4c42c95eafb2e8640d08d (diff) | |
download | rails-58d3b9042302d41f90fc129f12787d83f7bdade9.tar.gz rails-58d3b9042302d41f90fc129f12787d83f7bdade9.tar.bz2 rails-58d3b9042302d41f90fc129f12787d83f7bdade9.zip |
Speed up form_for by specializing extract_options! (at asakusa.rb)
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index ed83658140..6c3d2cf1b8 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -519,16 +519,18 @@ module ActionView # 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 |