# Update\_attributes for nested form

**URL:** <https://www.ruby-forum.com/t/update-attributes-for-nested-form/188690>\
**Category:** Rails\
**Created:** [May 16, 2010, 5:21pm UTC](https://www.ruby-forum.com/t/update-attributes-for-nested-form/188690 "2010-05-16T17:21:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![novicetoruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@novicetoruby](https://www.ruby-forum.com/u/novicetoruby)\
**Post date:** [May 16, 2010, 5:21pm UTC](https://www.ruby-forum.com/t/update-attributes-for-nested-form/188690/1 "2010-05-16T17:21:16Z")

</div>

I have two models.

model A  
has\_many :b  
def before\_validation\_on\_create  
…  
end

model B  
belongs\_to :a

In b’s controller and ‘update’ action, I have

a.update\_attributes(params[:a])

So when I was trying to create a new ‘b’, before\_validation\_on\_create is  
being called twice.

Pleas let me know if you guys have any suggestions.

Thanks in advance.
