1

My destroy action is not working, I am using Rails 4.x

My routes:

resources :subscription_users, only: [:new, :create, :destroy]

My view page:

<% @subscription_users.each do |user| %>
  <%= link_to "delete", admin_subscription_user_path(user), :method => :delete %>
<% end %>

controller:

def destroy
  ..
  ..
end

When I click on the link I get this error:

No route matches [GET] "/admin/subscription_users/9"

My view page layout has the following:

//= require jquery
// require jquery_ujs
// require turbolinks
//= require_tree ./bootstrap
Blankman
  • 259,732
  • 324
  • 769
  • 1,199

1 Answers1

1
//= require jquery_ujs

Writing this line in your js file instead of // require jquery_ujs most probably will solve your problem.

Doing this will include Rails unobtrusive scripting adapter for jQuery into resulting JS. Currently it is commented out.

In your case, it will hook up to the link and send proper request (HTTP DELETE) when you click it.

Baradzed
  • 578
  • 3
  • 10