For my application, I have user accounts that people can sign up. I use the devise gem for the setup.
I also have a users page that lists out all the u
I think you have in your routes.rb: resources :users
The problem is that you are not passing the user that you want to delete when clicking:
users/_user.html.erb
<%= link_to "Destroy", user, method: :delete, data: { confirm: "You sure?" } %>
See that in second param I added user instead of user_url.
users_controller.rb
def destroy
@user = User.find(params[:id])
if @user.destroy
redirect_to root_url, notice: "User deleted."
end
end
In controller I removed an @user.destroy. You were calling it twice.
Hope it helps!