Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chtelmko committed Oct 29, 2021
1 parent 6c9a840 commit 8254ca8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
22 changes: 22 additions & 0 deletions app/controllers/contact_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ def create
else
ContactMailer.contact_email(@contact).deliver
render json: { message: 'Your feedback has been submitted. We will reply as soon as possible.' }
def index
@contact = Pages.new(params[:pages])
end

def create
@contact = Pages.new(params[:pages])
@contact.request = request
respond_to do |format|
if @contact.deliver
# re-initialize Home object for cleared form
@contact = Pages.new
format.html { render 'index'}
format.js { flash.now[:success] = @message = "Your feedback has been submitted. We will reply as soon as possible." }
else
format.html { render 'index' }
format.js { flash.now[:error] = @message = "Message did not send." }
end
end
end

Expand All @@ -15,4 +32,9 @@ def create
def contact_params
params.require(:contact).permit(:email, :message, :name, :subject)
end
<<<<<<< Updated upstream
end
=======

end
>>>>>>> Stashed changes
1 change: 1 addition & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ class PagesController < ApplicationController
def index
@upcoming_meetings = upcoming_meetings
@next_meeting = next_meeting
@contact = contact_params
end
end
24 changes: 18 additions & 6 deletions app/models/contact.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
class Contact

class Home < MailForm::Base
attribute :name, :validate => true
attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
attribute :message
attribute :nickname, :captcha => true

# Declare the e-mail headers. It accepts anything the mail method
# in ActionMailer accepts.
def headers
{
:subject => "Contact Form Inquiry",
:to => "your_email@your_domain.com",
:from => %("#{name}" <#{email}>)
}
end

include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
Expand All @@ -15,8 +31,4 @@ def initialize(attributes = {})
send("#{name}=", value)
end
end

def persisted?
false
end
end
end
15 changes: 15 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,19 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker


# config/environments/development.rb

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors= true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: ENV["GMAIL_EMAIL"],
password: ENV["GMAIL_PASSWORD"],
authentication: 'plain',
enable_starttls_auto: true }
end
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

ActiveAdmin.routes(self)

post 'contact_us' => 'contact#create'
resources :pages, only: [:index, :new, :create]
# post 'contact_us' => 'contact#create'
get 'meetings' => 'meetings#index'
get 'twitter/timeline'

Expand Down

0 comments on commit 8254ca8

Please sign in to comment.