How to auto-generate passwords in Rails Devise?

后端 未结 4 1196
北海茫月
北海茫月 2021-02-03 20:26

I am trying out how Devise works with one of my projects for user authentication. There is a user requirement that their admin should be able to generate a batch of username and

4条回答
  •  北海茫月
    2021-02-03 21:06

    (quick caveat: I'm a rails newb)

    I tried the generate_token but it doesn't do what you think (look at the docs)

    (I'm using rails 3.0.5, and devise 1.1.7)

    What I found is that Devise will generate all that stuff for you in the background when you do:

    User.create!(:email => "me@example.com", :password => "password")
    

    Devise should create the encrypted_password, and salt for you. (pop open a console and try it out there)

提交回复
热议问题