Skip to content

Instantly share code, notes, and snippets.

@sj26
Created May 6, 2018 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sj26/e061f7c08576dae36fe162d0ca2866dc to your computer and use it in GitHub Desktop.
Save sj26/e061f7c08576dae36fe162d0ca2866dc to your computer and use it in GitHub Desktop.
rails/rails#32808 — demonstrate that mail is not eager loaded correctly during application initialization
gem "railties", "5.2.0"
gem "actionmailer", "5.2.0"
require "rails/application"
require "action_mailer/railtie"
class Application < Rails::Application
config.eager_load = true
end
$LOADED_FEATURES.size
# => 440
Application.initialize!
$LOADED_FEATURES.size
# => 887
Mail.autoload? :ContentTypeElement
# => "mail/elements/content_type_element" # i.e. true
$LOADED_FEATURES.grep /content_type_element/
# => [] # empty, so mail/elements/content_type_element is not loaded
Mail::ContentTypeElement
Mail.autoload? :ContentTypeElement
# => nil # i.e. false
$LOADED_FEATURES.size
# => 901
$LOADED_FEATURES.grep /content_type_element/
# => [".../mail-2.7.0/lib/mail/elements/content_type_element.rb"]
Mail.eager_autoload!
$LOADED_FEATURES.size
# => 921
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment