What is the difference between
parent.children << child.new
and
parent.children.build(params[:child])
What is the difference between
parent.children << child.new
and
parent.children.build(params[:child])
In the first one, the child is saved right away.
In the second, the child is not saved until the parent is saved
You may find this usefull:
http://blog.mrbrdo.net/2009/10/27/ruby-on-rails-new-vs-create-vs-build/
Sharagoz wrote:
In the first one, the child is saved right away.
In the second, the child is not saved until the parent is savedYou may find this usefull:
http://blog.mrbrdo.net/2009/10/27/ruby-on-rails-new-vs-create-vs-build/
Thanks Sharagoz. I got some idea about this.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs