Ask A Question

Notifications

You’re not receiving notifications from this thread.

Sharing Passwords Between Users Discussion

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'

Reply

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

Reply

Hello, yeah, in the first case, you get only one record and it doesn't have collection methods like "destroy_all"

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.