Mick Lasocki
Mick Lasocki

Reputation: 139

undefined local variable or method `resource_reset_password_token'

I'm trying to set up the Devise gem for my Rails 5.1.4 development environment. I follow various examples and I still have the same problem.

Once I want to remind an forgotten password I get undefined local variable or method `resource_reset_password_token' error. The same error appears once mailer is not being configured. Here are some details:

1. Error details

NameError in Devise::Passwords#create Showing /home/mk/thebest/app/views/devise/mailer/reset_password_instructions.html.erb where line #6 raised: undefined local variable or method `resource_reset_password_token' for #<#:0xb1e74800> Did you mean? resolve_assets_with Extracted source (around line #6):

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

2. config/environments/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. Environmental variables I've defined my env variables by adding them in that way:

sudo -H gedit /etc/environment

GMAIL_DOMAIN="gmail.com"
GMAIL_USERNAME="[email protected]"
GMAIL_PASSWORD="hereismypassword"

without quotas doesn't work as well

4. I've also allowed access in gmail

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

5. ENV

Typing ENV command I can see my env variables are properly set up

Please support

Upvotes: 0

Views: 567

Answers (1)

AntonTkachov
AntonTkachov

Reputation: 1784

Try

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

From this thread -> https://github.com/plataformatec/devise/issues/4446

Upvotes: 1

Related Questions