aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-28 19:46:17 +0000
committerPratik Naik <pratiknaik@gmail.com>2010-01-28 19:46:17 +0000
commit285361d1589002fcdd1584c07e6eb295f13c9f37 (patch)
tree2d50a69b3b59b6fb3cb7577b990fe3b1aaf58f4f /actionpack/lib/action_view/helpers/form_helper.rb
parentdfa19408651ecc82e2aeba95d93db871ba8a6e41 (diff)
parentd58398c2b5e98aad18dc72790230f338c10d145c (diff)
downloadrails-285361d1589002fcdd1584c07e6eb295f13c9f37.tar.gz
rails-285361d1589002fcdd1584c07e6eb295f13c9f37.tar.bz2
rails-285361d1589002fcdd1584c07e6eb295f13c9f37.zip
Merge remote branch 'mainstream/master'
Conflicts: railties/lib/rails/railtie.rb
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb36
1 files changed, 20 insertions, 16 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 157deebe40..b81925c7e7 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -262,23 +262,8 @@ module ActionView
# FormTagHelper#form_tag.
def form_for(record_or_name_or_array, *args, &proc)
raise ArgumentError, "Missing block" unless block_given?
-
options = args.extract_options!
-
- case record_or_name_or_array
- when String, Symbol
- object_name = record_or_name_or_array
- when Array
- object = record_or_name_or_array.last
- object_name = ActionController::RecordIdentifier.singular_class_name(object)
- apply_form_for_options!(record_or_name_or_array, options)
- args.unshift object
- else
- object = record_or_name_or_array
- object_name = ActionController::RecordIdentifier.singular_class_name(object)
- apply_form_for_options!([object], options)
- args.unshift object
- end
+ object_name = extract_object_name_for_form!(args, options, record_or_name_or_array)
concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}))
fields_for(object_name, *(args << options), &proc)
@@ -742,6 +727,25 @@ module ActionView
def radio_button(object_name, method, tag_value, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_radio_button_tag(tag_value, options)
end
+
+ private
+ def extract_object_name_for_form!(args, options, record_or_name_or_array)
+ case record_or_name_or_array
+ when String, Symbol
+ object_name = record_or_name_or_array
+ when Array
+ object = record_or_name_or_array.last
+ object_name = ActionController::RecordIdentifier.singular_class_name(object)
+ apply_form_for_options!(record_or_name_or_array, options)
+ args.unshift object
+ else
+ object = record_or_name_or_array
+ object_name = ActionController::RecordIdentifier.singular_class_name(object)
+ apply_form_for_options!([object], options)
+ args.unshift object
+ end
+ object_name
+ end
end
module InstanceTagMethods #:nodoc: