I'm going through the Ruby on Rails tutorial and having trouble getting my UserMailer preview to work.
The error I am getting is that when I go to the server, it says Mailer preview 'user_mailer/account_activation' not found
.
I am following the code step by step, but it is not working. Here is what I have.
app/mailers/user_mailer.rb class UserMailer < ApplicationMailer
def account_activation(user)
@user = user
mail to: user.email, subject: "Account activation"
end
test/mailers/previews/user_mailer_previews
class UserMailerPreview < ActionMailer::Preview
# Preview this email at
# http://localhost:3000/rails/mailers/user_mailer/account_activation
def account_activation
user = User.first
user.activation_token = User.new_token
UserMailer.account_activation(user)
end
config/environments/development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :test
host = 'localhost:3000'
config.action_mailer.default_url_options = { host: host, protocol: 'https' }
I have read and reread the code on the site https://www.railstutorial.org/book/account_activation and tried changing things out but had no luck
Thank you in advance!
edit: I actually already have a view, sorry should have included it earlier.
app/views/user_mailer/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) %>