aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-07-20 01:22:24 +0900
committerYehuda Katz <wycats@gmail.com>2009-07-20 01:22:24 +0900
commitb00cac4adc0413418ffd2c59b52c8f64acff406b (patch)
tree1696371c3ca1376d54310006744c146185f3c30b /actionpack
parent13e18dd94000cef2b2058b96d62de16b7d3a2200 (diff)
downloadrails-b00cac4adc0413418ffd2c59b52c8f64acff406b.tar.gz
rails-b00cac4adc0413418ffd2c59b52c8f64acff406b.tar.bz2
rails-b00cac4adc0413418ffd2c59b52c8f64acff406b.zip
Finish convert_to_object updates
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb4
-rw-r--r--actionpack/test/template/form_helper_test.rb6
2 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 56ee43496c..2b39d08035 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -1029,7 +1029,7 @@ module ActionView
def fields_for_with_nested_attributes(association_name, args, block)
name = "#{object_name}[#{association_name}_attributes]"
association = @object.send(association_name)
- explicit_object = args.first if args.first.respond_to?(:new_record?)
+ explicit_object = args.first.to_model if args.first.respond_to?(:to_model)
if association.is_a?(Array)
children = explicit_object ? [explicit_object] : association
@@ -1044,6 +1044,8 @@ module ActionView
end
def fields_for_nested_model(name, object, args, block)
+ object = convert_to_model(object)
+
if object.new_record?
@template.fields_for(name, object, *args, &block)
else
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 431ac35e54..883afd985b 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -43,6 +43,8 @@ silence_warnings do
end
class Tag
+ extend ActiveModel::APICompliant
+
attr_reader :id
attr_reader :post_id
def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end
@@ -59,6 +61,8 @@ silence_warnings do
end
class CommentRelevance
+ extend ActiveModel::APICompliant
+
attr_reader :id
attr_reader :comment_id
def initialize(id = nil, comment_id = nil); @id, @comment_id = id, comment_id end
@@ -71,6 +75,8 @@ silence_warnings do
end
class TagRelevance
+ extend ActiveModel::APICompliant
+
attr_reader :id
attr_reader :tag_id
def initialize(id = nil, tag_id = nil); @id, @tag_id = id, tag_id end