Guest User

Untitled

a guest
Feb 23rd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. def destroy
  2. @book = Book.find(params[:id])
  3.  
  4. respond_to do |format|
  5. if @book.destroy
  6. format.html { redirect_to books_url, notice: "Book was successfully deleted." }
  7. else
  8. format.html do
  9. error_messages = @book.errors.try(:messages)
  10. error_messages = error_messages[:base].join('. ') + '.' if error_messages.present?
  11. flash[:error] = "Book deletion failed. #{ error_messages }"
  12. redirect_to books_url
  13. end
  14. end
  15. format.json { head :no_content } # what should this be?
  16. end
  17. end
Add Comment
Please, Sign In to add comment