Skip to content Skip to sidebar Skip to footer

How To Prepopulate _form With Duplicated Image?

A user can click on a featured_inspiration to prepopulate a new _form with the data from that featured_inspiration. The data being :text and/or :image. This is so the user can save

Solution 1:

I wonder what you need to do is something like this:

@inspiration = existing_inspiration.dup
@inspiration.image_file_name = existing_inspiration.image_file_name

Leaving out the dupand doing the "deep" copies by hand.

Take a look at What is the easiest way to duplicate an activerecord record?. It is a bit old, but an enlightening discussion as well as pointers to some gems that make "deep" copies.

Post a Comment for "How To Prepopulate _form With Duplicated Image?"