Skip to content

Instantly share code, notes, and snippets.

@licatajustin
Last active August 12, 2016 13:15
Show Gist options
  • Save licatajustin/f348b5a5782bf5d38d35 to your computer and use it in GitHub Desktop.
Save licatajustin/f348b5a5782bf5d38d35 to your computer and use it in GitHub Desktop.
class Contact < ActiveRecord::Base
after_create :send_email
private
def send_email
ContactMailer.contact_email(self).deliver
end
end
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p>New Message from Hoot and Holla's Contact form, from <%= "#{@contact.name}, #{@contact.email}" %></p>
<p><%= @contact.phone %></p>
<p><%= @contact.event %></p>
<p><%= @contact.body %></p>
</body>
</html>
def contact_email(contact)
@contact = contact
mail(from: @contact.email, subject: 'Contact Form Message').deliver
end
def create
@contact = Contact.new(contact_params)
if @contact.save
flash[:success] = 'Message Sent.'
redirect_to new_contact_path
else
flash[:danger] = 'Error occurred, messgage not sent.'
redirect_to new_contact_path
end
end
@licatajustin
Copy link
Author

You're welcome @RuNpiXelruN -- sorry for the delay -- no notifications on Gists yet I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment