When the user clicks on delete, alert not show and go to this path course_path, but don’t delete the course.
def destroy
authorize @course
@course.destroy
respond_to do |format|
format.html { redirect_to courses_url, notice: "Course was successfully destroyed." }
format.json { head :no_content }
end
end
= link_to 'Destroy', course, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger
– Rails 7 default use Turbo by default, which changes how form submissions and link interactions work.
So need to change in view
= link_to ‘Destroy’, course, data: {turbo_method: :delete, turbo_confirm: ‘Are you sure?’ }, class: ‘btn btn-sm btn-danger’
Turbo is a set of complementary techniques for speeding up web applications without writing complex JavaScript. It’s part of the Hotwire suite, which aims to provide a modern, HTML-over-the-wire approach to building web applications.
Work with our skilled Ruby on Rails developers to accelerate your project and boost its performance.
Hire Ruby on Rails Developer