首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ArgumentError in Rails::MailersController#preview

ArgumentError in Rails::MailersController#preview
EN

Stack Overflow用户
提问于 2015-11-28 11:22:27
回答 1查看 387关注 0票数 1

我正在编写Michael的Rails教程中的10章,我面临的是关于帐户激活的问题。

代码语言:javascript
复制
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

user_mailer.rb

代码语言:javascript
复制
class UserMailer < ApplicationMailer

  def account_activation(user)
    @user = user
    mail to: user.email, subject: "Account activation"
  end

  def password_reset
    @greeting = "Hi"
    mail to: user.email
  end
end

account_activation.html.erb

代码语言:javascript
复制
<h1>Sample App</h1>

<p>Hi <%= @user.name %>,</p>

<p>
Welcome to the Sample App! Click on the link below to activate your account:
</p>

<%= link_to "Activate", edit_account_activation_url(@user.activation_token,
                                                    email: @user.email) %>

代码语言:javascript
复制
app/views/user_mailer/account_activation.html.erb:9:in `_app_views_user_mailer_account_activation_html_erb__2222007018826719766_70083837842380'
app/mailers/user_mailer.rb:5:in `account_activation'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-28 11:38:48

更新

default_url_options添加到config/environments/development.rb

代码语言:javascript
复制
config.action_mailer.default_url_options = { :host => '127.0.0.1', :port => 3000 }

代码语言:javascript
复制
config.action_mailer.default_url_options = { :host => 'localhost', :port => 3000 }
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33970728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档