This article notes the Rails 6.1 config settings.
config/application.rb
Set the time zone locally
config.time_zone = 'Tokyo'
config.active_record.default_timezone = :local
config/puma.rb
Use localhost: 3000 for development and unix socket for production
if ENV.fetch("RAILS_ENV", "development") == 'production'
bind "unix://#{Rails.root}/tmp/sockets/puma.sock"
else
port ENV.fetch("PORT") { 3000 }
end
config/environments/production.rb
Use redis for cache
cache_servers = %w(redis://localhost:6379/1)
config.cache_store = :redis_cache_store, {
url: cache_servers,
connect_timeout: 30,
read_timeout: 0.5,
write_timeout: 0.5,
reconnect_attemps: 1,
error_handler: -> (method:, returning:, exception:){
Rails.logger.warn "exception: #{exception}, method: #{method}, returning: #{returning}"
}
}
Use redis for sessions
config.session_store :redis_store,
servers: [{
host: 'localhost',
port: 6379,
db: 0,
namespace: 'sessions',
}],
key: "_session_name_",
expire_after: 30.minutes
Add gem to Gemfile to use redis with Rails
Gemfile
gem 'redis-rails'
config/webpacker.yml
If you are using webpack, can you detect html changes as well? The setting here needs to be considered
extensions:
...
- .html
...
Recommended Posts