Skip to content

Commit

Permalink
port latest Rails template
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Jul 27, 2019
1 parent bf7793e commit de7d4fe
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 60 deletions.
1 change: 0 additions & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: "[email protected]"
layout "mailer"
end
6 changes: 2 additions & 4 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'

# TODO: Removing the hack if https://github.com/rails/rails/pull/34777 merged

Expand Down
6 changes: 2 additions & 4 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../config/boot"
require "rake"
require_relative '../config/boot'
require 'rake'
Rake.application.run
21 changes: 10 additions & 11 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "fileutils"
require 'fileutils'

# path to your application root.
APP_ROOT = File.expand_path("..", __dir__)
APP_ROOT = File.expand_path('..', __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

FileUtils.chdir APP_ROOT do
# This script is a starting point to setup your application.
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file.

puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

# Install JavaScript dependencies
# system('bin/yarn')
Expand All @@ -27,11 +26,11 @@ FileUtils.chdir APP_ROOT do
# end

puts "\n== Preparing database =="
system! "bin/rails db:setup"
system! 'bin/rails db:prepare'

puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! "bin/rails restart"
system! 'bin/rails restart'
end
1 change: 0 additions & 1 deletion bin/webpack
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
ENV["NODE_ENV"] ||= "development"
Expand Down
1 change: 0 additions & 1 deletion bin/webpack-dev-server
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
ENV["NODE_ENV"] ||= "development"
Expand Down
16 changes: 8 additions & 8 deletions bin/yarn
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

APP_ROOT = File.expand_path("..", __dir__)
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
exec "yarnpkg", *ARGV
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
begin
exec "yarnpkg", *ARGV
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
15 changes: 15 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ class Application < Rails::Application
end
Rails.autoloaders.main.ignore("#{Rails.root}/app/overrides")

# Read ActionMailer config from config/mailer.yml
initializer "action_mailer.set_configs.set_yaml_configs", before: "action_mailer.set_configs" do |app|
next unless File.exist?(Rails.root.join("config", "mailer.yml"))

configure = app.config_for("mailer").deep_symbolize_keys
configure.each do |key, value|
setter = "#{key}="
unless app.config.action_mailer.respond_to? setter
raise "Can't set option `#{key}` to ActionMailer, make sure that options in config/mailer.yml are valid."
end

app.config.action_mailer.send(setter, value)
end
end

# Separate ActiveStorage key base
# initializer "app.active_storage.verifier", after: "active_storage.verifier" do
# config.after_initialize do |app|
Expand Down
2 changes: 1 addition & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize! # jbuilder new version will resolve the warning: https://github.com/rails/rails/issues/35505#issuecomment-470384945
Rails.application.initialize!
9 changes: 5 additions & 4 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true

# Do not eager load code on boot. This avoids loading your whole application
Expand Down
3 changes: 3 additions & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }

# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)

# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
Expand Down
13 changes: 13 additions & 0 deletions config/initializers/feature_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

# Define an application-wide HTTP feature policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
# Rails.application.config.feature_policy do |f|
# f.camera :none
# f.gyroscope :none
# f.microphone :none
# f.usb :none
# f.fullscreen :self
# f.payment :self, "https://secure.example.com"
# end
4 changes: 3 additions & 1 deletion config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
# Be sure to restart your server when you modify this file.

# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
Rails.application.config.filter_parameters += [
:password, :secret, :token, :_key, :auth, :crypt, :salt, :certificate, :otp, :access, :private, :protected, :ssn
]
1 change: 1 addition & 0 deletions config/initializers/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
# These inflection rules are supported but not enabled by default:
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym "OAuth"
inflect.acronym "API"
end
6 changes: 3 additions & 3 deletions config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
end

# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end
ActiveSupport.on_load(:active_record) do
self.include_root_in_json = true
end
3 changes: 3 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#
environment ENV.fetch("RAILS_ENV") { "development" }

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
Expand Down
3 changes: 0 additions & 3 deletions lib/monkey_patches/action_mailer.rb

This file was deleted.

17 changes: 0 additions & 17 deletions lib/monkey_patches/action_mailer/railtie+mailer.rb

This file was deleted.

2 changes: 1 addition & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file

0 comments on commit de7d4fe

Please sign in to comment.