从Devise上的子域发送电子邮件不起作用

时间:2012-05-07 02:22:58

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

我尝试配置发送的子设备发送的电子邮件(默认情况下所有链接都指向主域)。

我跟着这个: https://github.com/plataformatec/devise/wiki/How-To%3A-Send-emails-from-subdomains

问题是我收到此错误

NoMethodError in Devise/passwords#create

Showing     /Users/user/Sites/site/app/views/devise/mailer/reset_password_instructions.html.haml where line #6 raised:

undefined method `subdomain' for #<User:0x007fb0019be868>

我从视图中调用subdomain

# app/views/devise/mailer/confirmation_instructions.html
%strong= link_to t('devise.confirmation_instructions.confirm_my_account'), confirmation_url(@resource, :confirmation_token => @resource.confirmation_token, :subdomain => @resource.subdomain)

运行Rails 3.2.3,设计1.8.6

1 个答案:

答案 0 :(得分:1)

通过在环境配置中添加子域来解决。

config.action_mailer.default_url_options = { :host => "subdomain.domain.com" }