Skip to content

Commit

Permalink
Update rails config to 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp committed Mar 20, 2022
1 parent 0802577 commit 269b5d6
Show file tree
Hide file tree
Showing 16 changed files with 21,941 additions and 141 deletions.
8 changes: 4 additions & 4 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
#!/usr/bin/env ruby.ruby3.1
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
6 changes: 3 additions & 3 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
#!/usr/bin/env ruby.ruby3.1
require_relative "../config/boot"
require "rake"
Rake.application.run
25 changes: 25 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env ruby.ruby3.1
require "fileutils"

# path to your application root.
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 way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time 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 "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! "bin/rails restart"
end
102 changes: 24 additions & 78 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,89 +1,35 @@
require File.expand_path('../boot', __FILE__)

require_relative "boot"

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
# require "action_cable/engine"
require "rails/test_unit/railtie"

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

module SoftwareOO
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.i18n.enforce_available_locales = true
config.gettext_i18n_rails.default_options = %w[--sort-by-msgid]
config.gettext_i18n_rails.msgmerge_options = %w[--add-location --quiet]

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql

# Enable the asset pipeline
config.assets.enabled = true

# Skip frameworks you're not going to use
#config.frameworks -= [ :action_web_service, :active_resource ]

# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{Rails.root}/extras )

# Rails.root is not working directory when running under lighttpd, so it has
# to be added to load path
#config.load_paths << Rails.root unless config.load_paths.include? Rails.root

# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
# config.log_level = :debug

# Use the database for sessions instead of the file system
# (create the session table with 'rake create_sessions_table')
# config.action_controller.session_store = :active_record_store

# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector

# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc

config.action_controller.perform_caching = true

config.exceptions_app = self.routes

# See Rails::Configuration for more options
config.after_initialize do
# ExceptionNotifier.exception_recipients = CONFIG["exception_recipients"]
# ExceptionNotifier.sender_address = CONFIG["exception_sender"]
end unless Rails.env.test?

config.active_support.deprecation = :log
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.0
config.x = Hashie::Mash.new(config_for(:options))

# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end
end
5 changes: 2 additions & 3 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require "bundler/setup" # Set up gems listed in the Gemfile.
14 changes: 4 additions & 10 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)
GettextI18nRails.translations_are_html_safe = true
# Load the Rails application.
require_relative "application"

SoftwareOO::Application.configure do
# OBS API access
config.x = Hashie::Mash.new(config_for(:options))
end

# Initialize the rails application
SoftwareOO::Application.initialize!
# Initialize the Rails application.
Rails.application.initialize!
63 changes: 58 additions & 5 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,61 @@
SoftwareOO::Application.configure do
config.cache_store = :memory_store
require "active_support/core_ext/integer/time"

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

# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = false
config.assets.debug = true
# Needed for generated thumbnails
config.serve_static_files = true

# Show full error reports.
config.consider_all_requests_local = true

# Enable server timing
config.server_timing = true

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false

config.cache_store = :null_store
end

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

config.action_mailer.perform_caching = false

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise

# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []

# Suppress logger output for asset requests.
config.assets.quiet = true

# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
end
87 changes: 68 additions & 19 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,82 @@
SoftwareOO::Application.configure do
config.cache_store = :mem_cache_store, 'localhost:11211', {namespace: 'software', compress: true}
require "active_support/core_ext/integer/time"

# disabled until we figure the static.opensuse.org magic
# config.serve_static_files = false
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Compress JavaScripts and CSS
config.assets.js_compressor = :uglifier

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false

# Generate digests for assets URLs
config.assets.digest = true
# Code is not reloaded between requests.
config.cache_classes = true

config.assets.precompile += %w( jekyll.css main.js )
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true

# Full error reports are disabled and caching is turned on.
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"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true

# 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?

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com"

# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
config.log_level = :info

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

# Use a different cache store in production.
# config.cache_store = :mem_cache_store

# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "software_oo_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

# Don't log any deprecations.
config.active_support.report_deprecations = false

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

# Use a different logger for distributed setups.
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")

if ENV["RAILS_LOG_TO_STDOUT"].present?
log_level = String(ENV['RAILS_LOG_LEVEL'] || "warn").upcase
logger = ActiveSupport::Logger.new(STDOUT)
logger.level = Logger.const_get(log_level)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
config.log_level = log_level
end

config.cache_classes = true
end
Loading

0 comments on commit 269b5d6

Please sign in to comment.