Rails 3 + Devise: How to change other user passwords from the administrator role?

I developed a Rails 3 application with Devise for registration and login. I want to be able to change any user password that I provide. The solution I came up with (I did not have the opportunity to verify it yet) was to make a fake new registration with the password I selected, copy the password from the table entry into the corresponding user entry, and then delete the fake entry that I generated in the database. This is not the most elegant thing, but that’s all I have. I am waiting for the best offers.

+3
source share
1 answer

I might not understand the question, but it should be as simple as:

@user = User.find(<some id>)
@user.update_attributes(:password => 'anewpassword', :password_confirmation => 'anewpassword')

"anewpassword"

+4

All Articles