diff options
author | José Valim <jose.valim@gmail.com> | 2010-11-18 20:22:14 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-18 20:22:14 +0100 |
commit | e3d8331c5b543ea7ea2024d05bd79526d11341c0 (patch) | |
tree | a360f8418b53e3963e38bfce209e488dd95c208b /actionpack/lib/action_view | |
parent | be797750e6ce866ea08307f63bf35304a965c8d4 (diff) | |
download | rails-e3d8331c5b543ea7ea2024d05bd79526d11341c0.tar.gz rails-e3d8331c5b543ea7ea2024d05bd79526d11341c0.tar.bz2 rails-e3d8331c5b543ea7ea2024d05bd79526d11341c0.zip |
Revert "Remove deprecated form_for with strings or symbols"
This code was not deprecated. What was deprecated is the following:
form_for(:foo, @foo)
Which now should be rewritten as:
form_for(@foo, :as => :foo)
The following format is valid:
form_for(:foo)
This reverts commit be797750e6ce866ea08307f63bf35304a965c8d4.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index dec1ae6e4f..8c300ec745 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -303,9 +303,15 @@ module ActionView options[:html] ||= {} - object = record.is_a?(Array) ? record.last : record - object_name = options[:as] || ActiveModel::Naming.param_key(object) - apply_form_for_options!(record, options) + case record + when String, Symbol + object_name = record + object = nil + else + object = record.is_a?(Array) ? record.last : record + object_name = options[:as] || ActiveModel::Naming.param_key(object) + apply_form_for_options!(record, options) + end options[:html][:remote] = options.delete(:remote) builder = options[:parent_builder] = instantiate_builder(object_name, object, options, &proc) |