ruby-on-rails - 添加用户的名字以设计确认电子邮件模板

标签 ruby-on-rails postgresql devise devise-confirmable

我正在使用最新版本的 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/

相关文章:

ruby-on-rails - client_side_validations 'Cannot read property ' 用户[电子邮件 ]' of undefined'

ruby-on-rails - 如何在 ruby​​ activerecord 中使用通配符搜索 postgres JSONb 列

ruby-on-rails - 为了测试我的 Ruby on Rails 应用程序,您有什么建议?

sql - 从组中获取 ANY(col) 而不是 MIN(col)

javascript - 如何在Sequelize中的TIME类型的列中创建一个位置?

ruby-on-rails - 覆盖Devise的注册 Controller ,以在成功完成注册后允许重定向

ruby-on-rails - 无法测试 session [:user_id] value set in POST #create in SessionsController spec with RSpec/Rails

ruby-on-rails - 如何在需要 = true 时建立和保存父子记录?

sql - 如何在 PostgreSQL 中创建一个显示 "occurrence number"一天的伪列?

ruby-on-rails - 无法从 CanCan 'user_signed_in?' 模型访问 Devise 'Ability'