Last active
April 17, 2018 11:29
-
-
Save nicholasshirley/695047129b8f0d58f1a0e556df690d27 to your computer and use it in GitHub Desktop.
Example of selective attachment purge on controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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