문제

I have a user model which I created CRUD interface in admin namespace with some controller code and forms. The user model initially has username email password fields.

Then I setup devise to work with the same user model. The problem is devise encrypts passwords and puts them in encrypted_password feild, so the passwords and CRUD interface I created are useless now. I want the admin to have CRUD ability on user table and at the same time I want devise to work with it.

Possible solutions are 1) calling the devise controller's methods which would add a user taking care of encrypted passwords inside my controller, I don't know if that's possible and a nice way to do.

2) encrypting passwords myself and storing them in the same field devise does, I tried to figure out how devise encrypt passswords I found some posts but none of them worked. I even tried to add a custom encryption method, it didn't work either.

Can anyone help me with this please?

도움이 되었습니까?

해결책

I saved the user record by assigning email,password and username to new User object, but the problem is with just these attributes devise saves the record to User model but it does not encrypt the password which and encrypted_password field is empty it uses in authentication model.

I told my problem to https://twitter.com/coder_hsps and he suggested assigning same password to password_confirmation attribute in my controller and it worked

Thanks

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top