是否可以在一个字段中接收从 Faker 生成的另一个字段的值?

Is it possible to receive in one field the value of another field generated from a Faker?

@@base_url  = 'https://api-de-tarefas.herokuapp.com/users'
    @@body = 
    {
    "user": {
    "email": Faker::Internet.email,
    "password": Faker::Number.number(6),
    "password_confirmation": 
     }    
}.to_json

我正在尝试将 gem faker 在密码字段中生成的值传递给 password_verification 字段。

只需预先确定值:

@@base_url = 'https://api-de-tarefas.herokuapp.com/users'
password = Faker::Number.number(6)
@@body = {
  "user": {
    "email": Faker::Internet.email,
    "password": password,
    "password_confirmation": password
  }    
}.to_json

顺便说一句,你真的需要 class 个变量(从 @@ 开始)吗?我想不出很多情况下 class 变量是一个好的方法。