【问题标题】:Rails 3 - Change Devise host when generating confirmation emailsRails 3 - 生成确认电子邮件时更改设计主机
【发布时间】:2011-08-24 13:31:02
【问题描述】:

由于我的应用使用子域,我需要在注册过程中获取用户所在的子域。这可以使用request.subdomain 或我的自定义方法current_subdomain 完成,并且适用于所有应用程序。

但它永远不会继续设计。我的最后一次尝试是覆盖RegistrationsController,但完全没有成功。

class RegistrationsController < Devise::RegistrationsController
  def new
    @subdomain = current_subdomain
    puts @subdomain + " ON NEW"
    resource = build_resource({})
    respond_with_navigational(resource, @subdomain){ render_with_scope :new }
    #super
  end

  def create
    @subdomain = current_subdomain
    puts @subdomain + " ON CREATE"
    super
  end
end

并不是说puts 在此过程中可以完美运行。

电子邮件上生成的链接位于默认的设计视图中,我是这样配置的:

<p><%= link_to 'Confirm!', confirmation_url(@resource, :confirmation_token =>
@resource.confirmation_token, :host => @subdomain+".lvh.me:3000") %></p>

像往常一样,它说我的子域为零。我该怎么做?

谢谢。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 devise actionmailer


    【解决方案1】:

    devise wiki 中有一篇关于此的 wiki 文章:

    How To: Send emails from subdomains

    Devise 使用 ActionMailer 配置,您的代码不会影响这些配置。

    【讨论】:

      猜你喜欢
      • 2011-12-31
      • 2011-05-25
      • 1970-01-01
      • 2022-01-03
      • 2012-03-09
      • 2013-12-09
      • 2011-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多