【问题标题】:devise wrong token and url wrong设计错误的令牌和网址错误
【发布时间】:2013-11-20 16:34:01
【问题描述】:

我使用已启用确认的设计 (3.1.1)。

第一期

confirmation_url 不像预期的那样

我的/app/views/devise/mailer/confirmation_instructions.html.erb 包含

<p><%= link_to 'confirm', confirmation_url(@resource, :confirmation_token => @token) %></p>

预期是:

http://localhost:3000/?confirm/confirmation_token=3DXF7mw4KcJxtD698coCdH

但我得到了

?confirmation_token=3DXF7mw4KcJxtD698coCdH

出现这个错误

Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

第二期

令牌不匹配

confirmation_token.invalid

但我有

config.action_controller.default_url_options = {host: 'localhost', port: 3000}

test.rbdevelopment.rb

【问题讨论】:

    标签: ruby-on-rails devise ruby-on-rails-3.2 devise-confirmable


    【解决方案1】:

    不确定为什么令牌不匹配,但您可以通过以下方式轻松解决第一个问题:

    # development.rb and test.rb
    config.action_mailer.default_url_options = { :host => "localhost:3000" }
    

    至于生产环境配置,看你自己。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-10
      • 1970-01-01
      相关资源
      最近更新 更多