我正在使用最新版本的 Devise 运行 Rails 4.2.0。
我正在使用可确认模块 - 因此在用户注册后他们会收到一封确认电子邮件。
这是查看代码(在 Slim 中...而不是 ERB)
p
| Hi
= @user.first_name
| ,
p In order for me to send you the details, I'm going to need you to confirm your email address by clicking the link below:
= link_to "#{confirmation_url(@resource, confirmation_token: @token)}", confirmation_url(@resource, confirmation_token: @token)
这是用户 Controller 代码:
class Users::RegistrationsController < Devise::RegistrationsController
private
def user_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation)
end
end
数据库中有名字列(迁移已运行);然而,这不起作用。用户名所在的位置为空白。
如何配置 View 以包含用户的名字?
最佳答案
Devise 使用资源来抽象其正在管理的事物。
假设您的 @resource 设置正确,您应该能够执行以下操作
@resource.first_name
关于ruby-on-rails - 添加用户的名字以设计确认电子邮件模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29425657/