-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
faf373f
commit c09d0ef
Showing
7 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class ApplicationMailer < ActionMailer::Base | ||
default from: 'from@example.com' | ||
default from: 'system@railsurveys.com' | ||
layout 'mailer' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class SurveyMailer < ApplicationMailer | ||
default from: "[email protected]" | ||
|
||
def survey_created | ||
@username = params[:username] | ||
@survey = params[:survey] | ||
mail(to: "[email protected]", subject: "New survey created by #{ @username }") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> | ||
</head> | ||
<body> | ||
<h1>The survey <%= @survey.question %> was created by <%= @username %></h1> | ||
|
||
<h2>Answers:</h2> | ||
<% @survey.answers.each do |answer| %> | ||
<p><%= answer.description %></p> | ||
<% end %> | ||
<%= link_to "Survey Page", @survey %> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The survey <%= @survey.question %> was created by <%= @username %> | ||
|
||
Answers: | ||
<% @survey.answers.each do |answer| %> | ||
- <%= answer.description %> | ||
<% end %> | ||
|
||
Survey Page - <%= survey_url(@survey) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Preview all emails at http:https://localhost:3000/rails/mailers/survey_mailer | ||
class SurveyMailerPreview < ActionMailer::Preview | ||
def survey_created | ||
SurveyMailer.with(username: User.first.username, survey: Survey.first).survey_created | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class SurveyMailerTest < ActionMailer::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |