I wrote a method to encrypt the password using BCrypt and assign it to the password in User's model file.
After that, I created a seed file and put it in, but when I tried to get the encrypted password, it didn't work.
Rather, I can get it, but I don't understand why I can get it with such a description. I would like somebody to teach.
The column name for User password is
It is described as.
class User</pre> <p><code>seed.rb</code></p> <pre><code data-language = "Ruby">User.create! ( password: "hogehoge" )
And after inputting db: seed, at the terminal
rails r "puts User.first.hashed_password"
Then the encrypted password will be output.
At this time, why should the password of seed.rb be described as password instead of hashed_password?
First in seed.rb
Was described. In this case, the output to the terminal will be the hogehoge before it is encrypted.
When creating the table, I used hashed_password for the password column, so I thought I had to use the same hashed_password for seed.rb. What's wrong?
I would be grateful if anyone could tell me. Thank you.
Answer # 1
I think you wrote has_secure_password in model.
As a result, the process of "encrypting the password before saving and putting it in hashed_password" will be performed.
I haven't read the code, so it's probably from the behavior.
I think I'm defining a before_save hook.
- ruby on rails - i'm having trouble getting an actionview :: syntaxerror while implementing category selection using active_hash
- ruby - i'm having trouble getting data out across tables
- ruby - i'm having trouble setting environment variables for activeadmin: access denied for user'root' @'localhost' (using passwo
- i'm having trouble with ruby's word bingo algorithm
- ruby - i am having trouble saving the data of collection_check_boxes to the table
- ruby on rails - i'm having trouble installing rails
- ruby - [rails] i'm having trouble saving a table with the create action
- ruby - i'm having trouble solving the missing required keys: [: id] error
- ruby - i'm having trouble with rails nomethoderror (i want to get data with each method!)
- i'm having trouble getting an error when using bind with python tkinter
- ruby - [i'm having trouble with an error] cannot add foreign key constraint
- ruby - [rails] i'm having trouble with permission denied @ dir_s_mkdir -
- mysql - i'm having trouble getting the name of the person who posted the message to appear in the view
- ruby on rails - i'm having trouble solving the test error
- ruby on rails - i'm having trouble downloading homebrew to my mac
- [ruby] i'm having trouble with nomethoderror
- i'm having trouble installing the python library from github
- vba - i'm having trouble with excel macros i want to copy the contents of a sheet and paste it as it is on a new sheet
- ruby - conditional branching is complicated and i am in trouble
- ruby - passing variables using render partial
- ruby - deployment error on heroku
- ruby - output the total integer value held by each user
- ruby - i want to use the search method for active hash data
- ruby - destroy action does not respond
- ruby - how do you see the rails controller relative path? (carrierwave directory deleted)
- ruby - when deploying on capistrano, i get the error "access denied for user'ec2-user' @'localhost' (using password: no)&qu
- how to reflect the layout downloaded from the external site in ruby on rails?
- ruby - how nice! function routes do not pass well (relation) [rails]