Sharing Passwords Between Users Discussion
Discussion for
Sharing Passwords Between Users
Hello ROR developers, anyone facing a error when try to delete a user that you share a password ?
----------- code
def destroy
@password = current_user.passwords.find(params[:password_id]).destroy_all
redirect_to @password
end
---------------- error
undefined method `destroy_all'
Hey me from future, I tried to delete this question but I can not, the problem of course was me, the code I had to write is this :
def destroy
@password.user_passwords.where(user_id: params[:id]).destroy_all
redirect_to @password
end
after his everything works well
Hello, yeah, in the first case, you get only one record and it doesn't have collection methods like "destroy_all"