When I try to delete an attachment through an 'embeds_many' relation, using the _delete key generated by a form, the attachment is deleted but the record remains with it's paperclip
fields set to nil. How do I delete the record from the relation?
embeds_many :photos, cascade_callbacks => true
accepts_nested_attributes_for :photos, :allow_destroy => true
embedded_in :shopping_center, :inverse_of => :photos
When I submit my form to remove the first attachment here's the request that's generated:
However when the request is processed through the controller:
class UsersController < ApplicationController
#rendering code here
Paperclip issues the appropriate Deleting attachments messages, but then when I view the model, the record still exists. The underlying file has been removed, and all the paperclip fields on the Photo class have been set to nil.
How do I ensure the record is removed from the relation?