Created
November 17, 2014 20:58
-
-
Save liondancer/8653875f3049272b7091 to your computer and use it in GitHub Desktop.
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
class HomeController < ApplicationController | |
def index | |
end | |
def send_mail | |
name = params[:name] | |
email = params[:email] | |
body = params[:body] | |
UserMailer.contact_mail(name, email, body).deliver | |
end | |
end | |
view: | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> | |
<%= javascript_include_tag "application", "data-turbolinks-track" => true %> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
</head> | |
<body> | |
<p>You have received the following email from <%= "#{ @name } (#{ @email }):" %></p> | |
<p><%= @body %></p> | |
</body> | |
</html> | |
ActionMailer: | |
class UserMailer < ActionMailer::Base | |
default to: "[email protected]" | |
def contact_mail(name, email, body) | |
@name = name | |
@email = email | |
@body = body | |
mail(from: email, subject: "Contact Request") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment