Skip to content

Move controllers and concerns under app/controllers and app/concerns#2906

Closed
a-chernykh wants to merge 1 commit into
activeadmin:masterfrom
a-chernykh:f/applicationcontroller-reload
Closed

Move controllers and concerns under app/controllers and app/concerns#2906
a-chernykh wants to merge 1 commit into
activeadmin:masterfrom
a-chernykh:f/applicationcontroller-reload

Conversation

@a-chernykh

Copy link
Copy Markdown
Contributor

In order to get files automatically reloaded in Rails, these files should be under ActiveSupport::Dependencies.autoload_paths directory. Rails::Engine adds app/controllers path automatically to autoload_paths.

Reference: rails/rails#12195 (comment)

Closes #697

In order to get files automatically reloaded in Rails, these files should be under `ActiveSupport::Dependencies.autoload_paths` directory. `Rails::Engine` adds `app/controllers` path automatically to `autoload_paths`.

Reference: rails/rails#12195 (comment)

Closes activeadmin#697
@a-chernykh

Copy link
Copy Markdown
Contributor Author

@seanlinsley any issues with this PR?

@a-chernykh

Copy link
Copy Markdown
Contributor Author

@seanlinsley sorry for being pushy, but I really would love to hear back 😄 This caching problem still bothers me...

@thedarkone

Copy link
Copy Markdown

I'm not a user of active_admin and I see @andreychernih has put a lot of work into this.

The amount of code moved might be scary, so I'm thinking what if lib was added to autoload_paths? Then you might be reduce the amount of code that you have to shuffle around?

With lib in autoload_paths you would just need to remove any requires or autoloads for the controller classes and use require_dependency for some "inner" modules (such as in lib/active_admin/base_controller.rb you'd replace require 'active_admin/base_controller/authorization' with require_dependency 'active_admin/base_controller/authorization', require_dependency is require that works with auto-loadable constants). Removing require's and autoload's is necessary because we need Rails to magically load the files for us.

I've done some poking and prodding and here's what I have: thedarkone@2086cae.

Unfortunately I don't really have the time to work further on this, so @andreychernih if you want pick up on the autoload_paths += 'lib' approach, feel free to do so! I haven't run the tests or did anything but the really basic testing, maybe investigate why your approach doesn't require changes to register_page_controller and register_resource_controller, they are after-all creating new controllers that inherit from ActiveAdmin::ResourceController and if they are cached in Controllers#controller then they will not be picking up changes from ApplicationController etc.

@timoschilling

Copy link
Copy Markdown
Member

The idea behind this PR is good, but at the moment we have to many other problems in active admin with the autoloading / code reloading.

And there are some problems explicit with this PR:

  • (activeadmin)/app/controllers is not in the autoload_paths
  • renaming and moving of the controllers will brake things on the app side

This is way I'm going to close this, but I will create a issue which address this problem and add them to a 2.0 millstone.

@javierjulio

Copy link
Copy Markdown
Member

As maintainer I would be open to changes like these to improve the development experience. I’ve had much success with extracting view partials for a v4 release of ActiveAdmin (using TailwindCSS) that now reload on local development of the library. I’d love to have this for the host app. If someone wants to take this on that would be most helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApplicationController and Helpers are not being reloaded in Dev Env

5 participants