Skip to content

Commit e2a4301

Browse files
committed
adding rails 6 configurations
1 parent e5f5985 commit e2a4301

23 files changed

+356
-116
lines changed

bin/rails

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2+
load File.expand_path("spring", __dir__)
23
APP_PATH = File.expand_path('../config/application', __dir__)
3-
require_relative '../config/boot'
4-
require 'rails/commands'
4+
require_relative "../config/boot"
5+
require "rails/commands"

bin/rake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2-
require_relative '../config/boot'
3-
require 'rake'
2+
load File.expand_path("spring", __dir__)
3+
require_relative "../config/boot"
4+
require "rake"
45
Rake.application.run

bin/setup

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#!/usr/bin/env ruby
2-
require 'pathname'
3-
require 'fileutils'
4-
include FileUtils
2+
require "fileutils"
53

64
# path to your application root.
7-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
5+
APP_ROOT = File.expand_path('..', __dir__)
86

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

13-
chdir APP_ROOT do
14-
# This script is a starting point to setup your application.
11+
FileUtils.chdir APP_ROOT do
12+
# This script is a way to set up or update your development environment automatically.
13+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
1514
# Add necessary setup steps to this file.
1615

1716
puts '== Installing dependencies =='
@@ -20,15 +19,15 @@ chdir APP_ROOT do
2019

2120
# puts "\n== Copying sample files =="
2221
# unless File.exist?('config/database.yml')
23-
# cp 'config/database.yml.sample', 'config/database.yml'
22+
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
2423
# end
2524

2625
puts "\n== Preparing database =="
27-
system! 'bin/rails db:setup'
26+
system! 'bin/rails db:prepare'
2827

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

3231
puts "\n== Restarting application server =="
3332
system! 'bin/rails restart'
34-
end
33+
end

bin/spring

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
3+
gem "bundler"
4+
require "bundler"
5+
6+
# Load Spring without loading other gems in the Gemfile, for speed.
7+
Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring|
8+
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
9+
gem "spring", spring.version
10+
require "spring/binstub"
11+
rescue Gem::LoadError
12+
# Ignore when Spring is not installed.
13+
end
14+
end

config.ru

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file is used by Rack-based servers to start the application.
22

3-
require_relative 'config/environment'
3+
require_relative "config/environment"
44

55
run Rails.application
6+
Rails.application.load_server

config/application.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
require_relative 'boot'
1+
require_relative "boot"
22

3-
require 'rails/all'
3+
require "rails/all"
44

55
# Require the gems listed in Gemfile, including any gems
66
# you've limited to :test, :development, or :production.
77
Bundler.require(*Rails.groups)
88

99
module Topsekrit
1010
class Application < Rails::Application
11+
# Initialize configuration defaults for originally generated Rails version.
12+
config.load_defaults 5.0
13+
14+
# Configuration for the application, engines, and railties goes here.
15+
#
16+
# These settings can be overridden in specific environments using the files
17+
# in config/environments, which are processed later.
18+
#
19+
# config.time_zone = "Central Time (US & Canada)"
20+
# config.eager_load_paths << Rails.root.join("extras")
1121

1222
config.skylight.environments += ['staging']
1323
config.skylight.alert_log_file = true
1424

15-
16-
# config.skylight.environments += ['staging']
17-
18-
# Settings in config/environments/* take precedence over those specified here.
19-
# Application configuration should go into files in config/initializers
20-
# -- all .rb files in that directory are automatically loaded.
21-
2225
config.filter_parameters << :secret
2326
end
2427
end

config/boot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
22

3-
require 'bundler/setup' # Set up gems listed in the Gemfile.
3+
require "bundler/setup" # Set up gems listed in the Gemfile.

config/cable.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ development:
22
adapter: async
33

44
test:
5-
adapter: async
5+
adapter: test
66

77
production:
88
adapter: redis
9-
url: redis://localhost:6379/1
9+
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10+
channel_prefix: topsekrit_production

config/environment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Load the Rails application.
2-
require_relative 'application'
2+
require_relative "application"
33

44
# Initialize the Rails application.
55
Rails.application.initialize!

config/environments/development.rb

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
require "active_support/core_ext/integer/time"
2+
13
Rails.application.configure do
24
# Settings specified here will take precedence over those in config/application.rb.
35

4-
# In the development environment your application's code is reloaded on
5-
# every request. This slows down response time but is perfect for development
6+
# In the development environment your application's code is reloaded any time
7+
# it changes. This slows down response time but is perfect for development
68
# since you don't have to restart the web server when you make code changes.
79
config.cache_classes = false
810

@@ -12,35 +14,45 @@
1214
# Show full error reports.
1315
config.consider_all_requests_local = true
1416

15-
# Enable CSRF Tokens per form
16-
config.action_controller.per_form_csrf_tokens = true
17-
config.action_controller.forgery_protection_origin_check = true
18-
1917
# Enable/disable caching. By default caching is disabled.
20-
if Rails.root.join('tmp/caching-dev.txt').exist?
18+
# Run rails dev:cache to toggle caching.
19+
if Rails.root.join('tmp', 'caching-dev.txt').exist?
2120
config.action_controller.perform_caching = true
22-
config.action_mailer.perform_caching = true
21+
config.action_controller.enable_fragment_cache_logging = true
2322

2423
config.cache_store = :memory_store
2524
config.public_file_server.headers = {
26-
'Cache-Control' => 'public, max-age=172800'
25+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
2726
}
2827
else
2928
config.action_controller.perform_caching = false
30-
config.action_mailer.perform_caching = false
3129

3230
config.cache_store = :null_store
3331
end
3432

33+
# Store uploaded files on the local file system (see config/storage.yml for options).
34+
config.active_storage.service = :local
35+
3536
# Don't care if the mailer can't send.
3637
config.action_mailer.raise_delivery_errors = false
3738

39+
config.action_mailer.perform_caching = false
40+
3841
# Print deprecation notices to the Rails logger.
3942
config.active_support.deprecation = :log
4043

44+
# Raise exceptions for disallowed deprecations.
45+
config.active_support.disallowed_deprecation = :raise
46+
47+
# Tell Active Support which deprecation messages to disallow.
48+
config.active_support.disallowed_deprecation_warnings = []
49+
4150
# Raise an error on page load if there are pending migrations.
4251
config.active_record.migration_error = :page_load
4352

53+
# Highlight code that triggered database queries in logs.
54+
config.active_record.verbose_query_logs = true
55+
4456
# Debug mode disables concatenation and preprocessing of assets.
4557
# This option may cause significant delays in view rendering with a large
4658
# number of complex assets.
@@ -49,6 +61,19 @@
4961
# Suppress logger output for asset requests.
5062
config.assets.quiet = true
5163

64+
# Raises error for missing translations.
65+
# config.i18n.raise_on_missing_translations = true
66+
67+
# Annotate rendered view with file names.
68+
# config.action_view.annotate_rendered_view_with_filenames = true
69+
70+
# Use an evented file watcher to asynchronously detect changes in source code,
71+
# routes, locales, etc. This feature depends on the listen gem.
72+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
73+
74+
# Uncomment if you wish to allow Action Cable access from any origin.
75+
# config.action_cable.disable_request_forgery_protection = true
76+
5277
# Emails via Mailcatcher
5378
# `gem install mailcatcher` (it's not in the Gemfile)
5479
# Launche the server in the terminal with `mailcatcher`
@@ -58,11 +83,4 @@
5883
config.action_mailer.delivery_method = :smtp
5984
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
6085
config.action_mailer.default_options = {from: 'SecretLink.org Sharing <[email protected]>'}
61-
62-
# Raises error for missing translations
63-
# config.action_view.raise_on_missing_translations = true
64-
65-
# Use an evented file watcher to asynchronously detect changes in source code,
66-
# routes, locales, etc. This feature depends on the listen gem.
67-
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
6886
end

0 commit comments

Comments
 (0)