Skip to content

Commit

Permalink
added config for prod and dev mailers
Browse files Browse the repository at this point in the history
add letter opener for dev emails
  • Loading branch information
Dujota committed Jul 2, 2021
1 parent 1667df3 commit 2d098ab
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 14 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'dotenv-rails', groups: [:development, :test]
gem "dotenv-rails", groups: [:development, :test]

# Test
gem "rspec-rails", "~> 5.0", :groups => [:development, :test]
Expand All @@ -59,6 +59,9 @@ gem "rufo", "~> 0.13.0", :groups => [:development, :test]
# Debugging
gem "pry", "~> 0.14.1", :groups => [:development, :test]

# Dev Mailer
gem "letter_opener", group: :development

# Auth
gem "devise", "~> 4.8"
gem "cancancan", "~> 3.2"
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
bcrypt (3.1.16)
bcrypt (3.1.16-java)
bindex (0.8.1)
Expand Down Expand Up @@ -98,6 +100,10 @@ GEM
concurrent-ruby (~> 1.0)
jbuilder (2.11.2)
activesupport (>= 5.0.0)
launchy (2.5.0)
addressable (~> 2.7)
letter_opener (1.7.0)
launchy (~> 2.2)
listen (3.5.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -133,6 +139,7 @@ GEM
coderay (~> 1.1)
method_source (~> 1.0)
spoon (~> 0.0)
public_suffix (4.0.6)
puma (5.3.2)
nio4r (~> 2.0)
puma (5.3.2-java)
Expand Down Expand Up @@ -263,6 +270,7 @@ DEPENDENCIES
dotenv-rails
factory_bot_rails (~> 6.2)
jbuilder (~> 2.7)
letter_opener
listen (~> 3.3)
pg
pry (~> 0.14.1)
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/inquiries_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
class InquiriesController < ApplicationController
skip_before_action :verify_authenticity_token
load_and_authorize_resource

def create
binding.pry

respond_to do |format|
if @inquiry.save
CustomerMailer.with(inquiry: @inquiry).inquiry_submitted.deliver_now
Expand Down
7 changes: 7 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@

# NGROK
config.hosts << ENV["NGROK"] if ENV["NGROK"]

# Mailer Configuration
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.perform_deliveries = true

# Default Mailer
config.action_mailer.default_url_options = { :host => "localhost:3000" }
end
35 changes: 24 additions & 11 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
config.eager_load = true

# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
Expand All @@ -22,7 +22,7 @@

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
Expand Down Expand Up @@ -53,7 +53,7 @@
config.log_level = :info

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand All @@ -62,12 +62,6 @@
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "resume_site_production"

config.action_mailer.perform_caching = false

# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
Expand All @@ -89,9 +83,9 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
config.logger = ActiveSupport::TaggedLogging.new(logger)
end

# Do not dump schema after migrations.
Expand All @@ -117,4 +111,23 @@
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session

# Action Mailer Settings
config.action_mailer.perform_caching = false

# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false

config.action_mailer.delivery_method = :smtp

config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["SMTP_DOMAIN"],
user_name: ENV["SMTP_USER"],
password: ENV["SMTP_PASSWORD"],
authentication: "plain",
enable_starttls_auto: true,
}
end
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rails.application.routes.draw do
# Pages
root "pages#home"
get "contact", to: "pages#contact"
# get "contact", to: "pages#contact"

# Admin Routes
devise_for :users, path: "admin",
Expand All @@ -19,5 +19,5 @@
# Blog Posts
resources :posts, only: %i[index show]

resources :inqury, only: %i[create]
resources :inquiries, only: %i[create]
end

0 comments on commit 2d098ab

Please sign in to comment.