Skip to content

Commit

Permalink
Fix autoload issue with ActiveAdmin
Browse files Browse the repository at this point in the history
Zeitwerk breaks the override pattern e.g expected file
/get-help-to-retrain/app/admin/categories.rb to define constant
Categories, but didn't (NameError), we need to ignore the
exceptions.

This approach clashes with ActiveAdmin in our case, as all related
files live under /admin but do not have the expected structure.

The fix is to ignore the files that break this expected behaviour,
by doing something like:

Rails.autoloaders.main.ignore("#{Rails.root}/app/admin")

Resource:
rails/rails#36100
  • Loading branch information
Octavian Neguletu committed Sep 2, 2019
1 parent 0bbb0ed commit 9243ec3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions config/application.rb
Expand Up @@ -21,6 +21,7 @@ module GetHelpToRetrain
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults '6.0'
Rails.autoloaders.main.ignore("#{Rails.root}/app/admin")

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
Expand Down
9 changes: 5 additions & 4 deletions config/database.yml
Expand Up @@ -82,8 +82,9 @@ cucumber:
#
production:
<<: *default
host: <%= ENV['DB_HOST'] %>
database: <%= ENV['DB_DATABASE'] %>
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
# host: <%= ENV['DB_HOST'] %>
# database: <%= ENV['DB_DATABASE'] %>
# username: <%= ENV['DB_USERNAME'] %>
# password: <%= ENV['DB_PASSWORD'] %>
database: get_help_to_retrain_development

2 changes: 1 addition & 1 deletion config/environments/development.rb
Expand Up @@ -4,7 +4,7 @@
# In the development environment your application's code is reloaded on
# every request. 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
config.cache_classes = true

# Do not eager load code on boot.
config.eager_load = false
Expand Down

0 comments on commit 9243ec3

Please sign in to comment.