form mailer
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: https://github.com/HubFeenixMakers/merged
|
remote: https://github.com/HubFeenixMakers/merged
|
||||||
revision: b44c29ff50bbfc07b04a6064804ac3684eed151d
|
revision: 5b0ccafc0e78cc72d95865abf001c7b65b69a96f
|
||||||
specs:
|
specs:
|
||||||
merged (0.1.0)
|
merged (0.1.0)
|
||||||
active_hash
|
active_hash
|
||||||
@ -146,7 +146,7 @@ GEM
|
|||||||
formatador (1.1.0)
|
formatador (1.1.0)
|
||||||
friendly_id (5.5.0)
|
friendly_id (5.5.0)
|
||||||
activerecord (>= 4.0.0)
|
activerecord (>= 4.0.0)
|
||||||
git (1.13.1)
|
git (1.13.2)
|
||||||
addressable (~> 2.8)
|
addressable (~> 2.8)
|
||||||
rchardet (~> 1.8)
|
rchardet (~> 1.8)
|
||||||
globalid (1.1.0)
|
globalid (1.1.0)
|
||||||
@ -224,7 +224,7 @@ GEM
|
|||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
lumberjack (1.2.8)
|
lumberjack (1.2.8)
|
||||||
mail (2.8.0.1)
|
mail (2.8.1)
|
||||||
mini_mime (>= 0.1.1)
|
mini_mime (>= 0.1.1)
|
||||||
net-imap
|
net-imap
|
||||||
net-pop
|
net-pop
|
||||||
@ -256,7 +256,7 @@ GEM
|
|||||||
net-protocol
|
net-protocol
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nio4r (2.5.8)
|
nio4r (2.5.8)
|
||||||
nokogiri (1.14.0-x86_64-linux)
|
nokogiri (1.14.1-x86_64-linux)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
notiffany (0.1.3)
|
notiffany (0.1.3)
|
||||||
nenv (~> 0.1)
|
nenv (~> 0.1)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class ApplicationMailer < ActionMailer::Base
|
class ApplicationMailer < ActionMailer::Base
|
||||||
default from: "from@example.com"
|
default from: "info@hubfeenix.fi" , bcc: "info@hubfeenix.fi"
|
||||||
layout "mailer"
|
layout "mailer"
|
||||||
end
|
end
|
||||||
|
8
app/mailers/form_mailer.rb
Normal file
8
app/mailers/form_mailer.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
class FormMailer < ApplicationMailer
|
||||||
|
default from: "info@hubfeenix.fi" , bcc: "info@hubfeenix.fi"
|
||||||
|
|
||||||
|
def received(data)
|
||||||
|
@data = data
|
||||||
|
mail(subject: "We have received your request")
|
||||||
|
end
|
||||||
|
end
|
21
app/views/form_mailer/received.html.haml
Normal file
21
app/views/form_mailer/received.html.haml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
%h1 Hello
|
||||||
|
= @data["name"]
|
||||||
|
|
||||||
|
%p
|
||||||
|
This is an automated message confirming that we have receievd your request
|
||||||
|
|
||||||
|
%p
|
||||||
|
Your form input is listed below. If you need to amend or correct, you may reply
|
||||||
|
to this email.
|
||||||
|
|
||||||
|
%p
|
||||||
|
You will hear from us in the next few days
|
||||||
|
|
||||||
|
%p
|
||||||
|
Your friendly Feenix Bot
|
||||||
|
|
||||||
|
%h3 Data received
|
||||||
|
|
||||||
|
- @data.each do |name , value|
|
||||||
|
%p
|
||||||
|
= "#{name}: #{value}"
|
17
app/views/form_mailer/received.text.haml
Normal file
17
app/views/form_mailer/received.text.haml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
="Hello #{@data['name']}"
|
||||||
|
|
||||||
|
This is an automated message confirming that we have receievd your request
|
||||||
|
|
||||||
|
Your form input is listed below. If you need to amend or correct, you may reply
|
||||||
|
to this email.
|
||||||
|
|
||||||
|
You will hear from us in the next few days
|
||||||
|
|
||||||
|
Your friendly Feenix Bot
|
||||||
|
|
||||||
|
|
||||||
|
Data received
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- @data.each do |name , value|
|
||||||
|
= "#{name}: #{value}"
|
@ -1,10 +1,11 @@
|
|||||||
class FormHandler
|
class FormHandler
|
||||||
|
|
||||||
def handle_form(section , data )
|
def handle_form(section , data )
|
||||||
puts "Section on page : #{section.page.name}"
|
@data = data
|
||||||
data.each do |name , value|
|
data.each do |name , value|
|
||||||
puts "#{name}: #{value}"
|
puts "#{name}: #{value}"
|
||||||
end
|
end
|
||||||
|
FormMailer.received(data).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
12
test/mailers/form_mailer_test.rb
Normal file
12
test/mailers/form_mailer_test.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class FormMailerTest < ActionMailer::TestCase
|
||||||
|
test "received" do
|
||||||
|
mail = FormMailer.received
|
||||||
|
assert_equal "Received", mail.subject
|
||||||
|
assert_equal ["to@example.org"], mail.to
|
||||||
|
assert_equal ["from@example.com"], mail.from
|
||||||
|
assert_match "Hi", mail.body.encoded
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
9
test/mailers/previews/form_mailer_preview.rb
Normal file
9
test/mailers/previews/form_mailer_preview.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Preview all emails at http://localhost:3000/rails/mailers/form_mailer
|
||||||
|
class FormMailerPreview < ActionMailer::Preview
|
||||||
|
|
||||||
|
# Preview this email at http://localhost:3000/rails/mailers/form_mailer/received
|
||||||
|
def received
|
||||||
|
FormMailer.received
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Reference in New Issue
Block a user