albums_controller.rb:
lass AlbumsController < ApplicationController
before_action :set_album, only: [:show, :edit, :update, :destroy]
def destroy
if @album.destroy
redirect_to albums_url, notice: 'Album was successfully destroyed.'
else
redirect_to albums_url, error: 'Album destroy failed.'
end
end
private
def set_album
@album = Album.find(params[:id])
end
end
I would like to catch an exception for Album.find(). Accordingly , I added:
rescue_from Exception, with: :flash_error
def flash_error
flash_message :error, 'Something went wrong..'
end
I noted some of the above as _FIND_, _FLASH_, _DEST_, and I would like to go through all of them in this order. I tried to delete an album that does not exist to run it. I got a blank page with the url for albums / (: id) (the one I was trying to remove), so I suppose I'm stuck in parts _FLASH_.
What should I do to call destroyaction (I mean the original, called as rescue_form, because it can catch other exceptions for other controller actions). And how to get a better message than Something went wrong?
- ( _DEST_), , , .