Skip to content

Instantly share code, notes, and snippets.

@nicholasshirley
Last active April 17, 2018 11:29
Show Gist options
  • Save nicholasshirley/695047129b8f0d58f1a0e556df690d27 to your computer and use it in GitHub Desktop.
Save nicholasshirley/695047129b8f0d58f1a0e556df690d27 to your computer and use it in GitHub Desktop.
Example of selective attachment purge on controller
@resource = Training::Resource.find(params[:id])
if params[:attachment_id]
@resource.files.find_by_id(params[:attachment_id]).purge
flash[:success] = 'The resource has been deleted'
redirect_to edit_trainings_resource_path(@resource)
else
@resource.destroy
flash[:success] = 'The resource has been deleted'
redirect_to trainings_resources_path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment