I have a rails 7 app. Here are the relevant pieces of code:
/app/mailers/team_mailer.rb
def final_survey_nag_email
@leader_name = params[:leader_name]
@leader_email = params[:email]
@team_name = params[:team]
mail(to: @leader_email, subject: "Your Teams Progress")
end
spec/mailers/previews/team_preview.rb
def final_survey_nag_email
@leader_name = Team.last.leader_name
@team_name = "Team Candler"
TeamMailer.with(team_name: @team_name, leader_name: @leader_name, subject: "Your Teams Progress").final_survey_nag_email
end
/app/views/team_mailer/final_survey_nag_email.html.erb
Hi <%= @leader_name %>! A couple of months ago you created the team <b><%= @team_name %></b> for the Team
When viewing a preview of the email above at rails/mailers/team/final_survey_nag_email
@leader_name is displaying a value, but @team_name is not. What am I missing?
CodePudding user response:
you are setting team_name here
TeamMailer.with(team_name: @team_name, leader_name: @leader_name, subject: "Your Teams Progress")
but then you try and access team
@team_name = params[:team]
so you should fix your preview to look for params[:team_name]