Ruby -v 2.6.4

问题描述 投票:0回答:1

SecureRandom.base58(8)im in the process of creating a form that then creates a user and sends out a generated password in an email. I'm using devise, for reference. The password must be "random" as directed, so ...

Why don't you use @generated_pass = SecureRandom.base58(8)before_save

or <%= f.hidden_field :password, class: 'form-control', value: @generated_pass %>before_validationvalue: callbacks on you model ?

This type of data should not be modified or altered in the view or controller.<%= f.hidden_field :password, class: 'form-control', value: SecureRandom.base58(8) %>Something like this in your User model: RoR

我正在创建一个表单,然后创建一个用户,并在邮件中发送一个生成的密码。我使用devise,供参考。密码必须是 "随机 "的,按照指示,所以
ruby-on-rails ruby forms instance-variables hidden-field
1个回答
0
投票

然后在视图中调用该变量。我无法工作的字段是。当我输入一个可接受的字符串(1个数字,至少1个大写字母)作为表格中的 所以我知道不是表单坏了,我在用这个变量提交时得到的问题是回滚,没有其他信息。我是不是把这个变量声明错了?我是否应该创建一个方法,然后以某种方式调用该方法作为值?此外,我还尝试了--------。

徒劳无功。

任何建议都是欢迎的,thankyou.Rails -v 5.0.7.2

© www.soinside.com 2019 - 2024. All rights reserved.