Last active
January 30, 2022 12:30
-
-
Save goofansu/8ab92ba07a9309ac0bbab1089d4ffbe1 to your computer and use it in GitHub Desktop.
autoloader loads class unexpectedly in classic mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
ActionController::Railtie.initializer "puts default_protect_from_forgery when ActionController::Base is loaded" do | |
ActiveSupport.on_load(:action_controller_base) do | |
puts "default_protect_from_forgery is #{Rails.application.config.action_controller.default_protect_from_forgery}, expected: false" | |
end | |
end | |
ActionController::Railtie.initializer "puts default_protect_from_forgery when application is initialized" do | |
ActiveSupport.on_load(:after_initialize) do | |
puts "default_protect_from_forgery is #{Rails.application.config.action_controller.default_protect_from_forgery}, expected: false" | |
end | |
end | |
# require "action_mailer/railtie" | |
# require "action_mailbox/engine" | |
# require "action_text/engine" | |
require "action_view/railtie" | |
# require "action_cable/engine" | |
require "sprockets/railtie" | |
require "rails/test_unit/railtie" | |
# Require the gems listed in Gemfile, including any gems | |
# you've limited to :test, :development, or :production. | |
Bundler.require(*Rails.groups) | |
module RailsConfig | |
class Application < Rails::Application | |
# Initialize configuration defaults for originally generated Rails version. | |
config.load_defaults 6.1 | |
# 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") | |
# Don't generate system test files. | |
config.generators.system_tests = nil | |
config.before_configuration do | |
puts "before_configuration" | |
end | |
config.before_initialize do | |
puts "before_initialize" | |
end | |
config.after_initialize do | |
puts "after_initialize" | |
end | |
initializer "before_initialize hook" do |app| | |
ActiveSupport.on_load(:before_initialize) do | |
puts "ActiveSupport.on_load(:before_initialize) runs at the end of before_initialize" | |
end | |
end | |
initializer "after_initialize hook" do |app| | |
ActiveSupport.on_load(:after_initialize) do | |
puts "ActiveSupport.on_load(:after_initialize) runs at the end of after_initialize" | |
end | |
end | |
puts "application.rb loaded" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
ruby '2.6.5' | |
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' | |
gem 'rails', '~> 6.1.3' | |
# Use sqlite3 as the database for Active Record | |
gem 'sqlite3', '~> 1.4' | |
# Use Puma as the app server | |
gem 'puma', '~> 5.0' | |
# Use SCSS for stylesheets | |
gem 'sass-rails', '>= 6' | |
# Use Active Model has_secure_password | |
# gem 'bcrypt', '~> 3.1.7' | |
group :development, :test do | |
# Call 'byebug' anywhere in the code to stop execution and get a debugger console | |
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] | |
end | |
group :development do | |
gem 'listen', '~> 3.3' | |
end | |
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem | |
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] | |
gem 'wechat', '~> 0.12.0' # classic mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_configuration | |
application.rb loaded | |
before_initialize | |
default_protect_from_forgery is true, expected: false | |
config/initializers loaded | |
ActiveSupport.on_load(:before_initialize) runs at the end of before_initialize | |
after_initialize | |
default_protect_from_forgery is false, expected: false | |
ActiveSupport.on_load(:after_initialize) runs at the end of after_initialize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment