문제

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?

도움이 되었습니까?

해결책

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 :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top