1

I am working on 10 chapter in The Ruby on Rails Tutorial by Michael Hartl, I am facing the issue regarding account activation

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

user_mailer.rb

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

<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) %>

enter image description here

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'
maheshkumar
  • 395
  • 2
  • 5
  • 14

1 Answers1

3

UPDATE

Add default_url_options to config/environments/development.rb

config.action_mailer.default_url_options = { :host => '127.0.0.1', :port => 3000 }

OR

config.action_mailer.default_url_options = { :host => 'localhost', :port => 3000 }
Prashant4224
  • 1,551
  • 1
  • 14
  • 21
  • `Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true ` – maheshkumar Nov 28 '15 at 11:45
  • This is the default_url_options that I have set in the development.rb `config.action_mailer.default_url_options = { :host => '127.0.0.1', :port => 3000 }` – maheshkumar Nov 28 '15 at 11:46
  • 1
    I stopped the server and then restarted it, it's working now. Thanks – maheshkumar Nov 28 '15 at 11:54