未定义的局部变量或方法`resource_reset_password_token'

时间:2017-11-07 12:55:11

标签: ruby-on-rails devise

我正在尝试为 Rails 5.1.4 开发环境设置设计 gem。我遵循各种例子,我仍然遇到同样的问题。

一旦我想提醒忘记密码,我就会得到未定义的局部变量或方法`resource_reset_password_token'错误。一旦未配置邮件程序,则会出现相同的错误。以下是一些细节:

1。错误详情

设计中的 ameError ::密码#create 显示/home/mk/thebest/app/views/devise/mailer/reset_password_instructions.html.erb,其中第6行引发: 未定义的局部变量或方法`resource_reset_password_token'用于#<#:0xb1e74800> 你的意思是? resolve_assets_with 提取的来源(第6行):

<p><%= link_to t('.action'), edit_password_url(@resource, :reset_password_token => resource_reset_password_token) %></p>

2。配置/环境/ development.rb

  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: ENV["GMAIL_DOMAIN"],
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["GMAIL_USERNAME"],
    password: ENV["GMAIL_PASSWORD"]
   }

第3。环境变量 我通过以这种方式添加它来定义我的env变量:

sudo -H gedit / etc / environment

GMAIL_DOMAIN="gmail.com"
GMAIL_USERNAME="hereismyemail@gmail.com"
GMAIL_PASSWORD="hereismypassword"
没有配额的

也不起作用

4。我也允许在gmail中访问

使用

http://www.google.com/accounts/DisplayUnlockCaptcha

5。 ENV

键入ENV命令我可以看到我的env变量已正确设置

请支持

1 个答案:

答案 0 :(得分:0)

尝试

<p><%= link_to t('.action'), edit_password_url(@resource, :reset_password_token => @token) %></p>

从这个帖子 - &gt; https://github.com/plataformatec/devise/issues/4446