【发布时间】: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