The below code prepopulates a new _form, but once the user saves the form it will update the old Inspiration
instead of creating a new Inspiration
.
controller
def new
if params[:inspiration_id]
@inspiration = Inspiration.find(params[:inspiration_id])
@inspiration = current_user.inspirations.build # Is there a way to find and then build?
else
@inspiration = current_user.inspirations.build
end
end
path
new_inspiration_path(inspiration_id: inspiration.id)
How can we use @inspiration
to first Inspiration.find(params[:inspiration_id])
then to current_user.inspirations.build
?