As an admin I want to delete users from my database. In my view I list all users from my database. When I click the button I want the user to be deleted. I come up with this so far, but it wont give me the right solution. Thx for your time!
This is my view
@users.each do |user|
button_to 'Delete User',"#", :controller => "users", :action => "delete_user", :id => user.id, :confirm => "Are you sure?", :method => :delete
This is my controller:
class UsersController < Devise::RegistrationsController
def delete_user
@deleted_user = User.find(params[:id])
@deleted_user.destroy
end
end
You have to create a controller (or an action in a exsisting controller )to manage the user model. try to look here , strip out the cancan part.
have a nice day!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.