Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def destroy
- @book = Book.find(params[:id])
- respond_to do |format|
- if @book.destroy
- format.html { redirect_to books_url, notice: "Book was successfully deleted." }
- else
- format.html do
- error_messages = @book.errors.try(:messages)
- error_messages = error_messages[:base].join('. ') + '.' if error_messages.present?
- flash[:error] = "Book deletion failed. #{ error_messages }"
- redirect_to books_url
- end
- end
- format.json { head :no_content } # what should this be?
- end
- end
Add Comment
Please, Sign In to add comment