提交 b00cac4a 编写于 作者: Y Yehuda Katz

Finish convert_to_object updates

上级 13e18dd9
......@@ -1029,7 +1029,7 @@ def nested_attributes_association?(association_name)
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 @@ def fields_for_with_nested_attributes(association_name, args, block)
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
......
......@@ -43,6 +43,8 @@ def relevances_attributes=(attributes); end
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 @@ def relevances_attributes=(attributes); end
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 @@ def value
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册