Question

I'm using the paperclip gem to attach images to objects in my rails app. When I update an object and don't attach a file, it won't erase the existing image. However when I don't attach a file to nested objects in the form it deletes the old image if nothing is attached. How do I prevent this from happening?

Was it helpful?

Solution

I figured out the problem ... With Rails 4 strong parameters I didn't have the parameter id included. The result is that the attributes are now:

params.require(:event).permit(:name, :logo, :description, :start_time, :end_time,speakers_attributes:[:id,:name,:short_bio,:avatar,:contact,:_destroy])

Hopefully this saves someone else some pain :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top