0
RoutingError (No route matches [GET] "/2/delete"):

routes.rb

delete "/:id/delete", to: "login#deleted", as: "login_deleted"

controller.rb

def destroy
  @ambil_id = Logined.find(params[:id])
  params[:id] = nil

  if @ambil_id.destroy
    redirect_to login_index_path, notice: "data berhasil dihapus"
  else
    render :index
  end
end

index.html.erb

<td><%= link_to 'Hapus', login_deleted_path(data.id), data: { confirm: 'Ingin menghapus task ini?' }, method: :delete %>
Chris
  • 26,361
  • 5
  • 21
  • 42
  • 1
    `method: :delete` only works when you have the necessary javascript libraries included. How to do to that depends on your Rails version. What version of Rails do you use? – spickermann Jan 26 '22 at 07:11
  • [Similar question here, for example](https://stackoverflow.com/a/46320966/1954610). In short, if you want to use this approach then a common setup seems to involve adding `jquery_ujs`. (Or potentially try to find another solution that doesn't involve `jquery`!!) – Tom Lord Jan 26 '22 at 11:09
  • i use rails version Rails 7.0.1 ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux] – kardotinambunan Jan 27 '22 at 02:58

0 Answers0