How do you build a child with a has_many?

hi,
i just read that you use model.build_whatever to save a child
object…but what do you call when you have many children?

reports has_many images…

when i have 2 or more file fields in a form, what do i use to save the
images to my report? when report has_one image, i just call
@model.build_image(params[:something]) but how about if report has_many
images?

thanks.

On 2/25/07, mixplate [email protected] wrote:

images to my report? when report has_one image, i just call
@model.build_image(params[:something]) but how about if report has_many
images?

@report.images.build(params[:first_image])
@report.images.build(params[:second_image])

If you want to find out more about this, then see:
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#M000642

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs