Skip to content

ApplicationController and Helpers are not being reloaded in Dev Env #697

Closed as not planned

Description

why is the application_controller cached?
and how can i disable this?

cheers

Activity

  1. groe commented on Mar 14, 2012

    @groe

    What exactly is the problem; what do you mean? And how is (caching of) your ApplicationController related to ActiveAdmin?

  2. elia commented on May 15, 2012

    @elia
    Member

    @pcreux I'm having the same problem (v0.4.3)

  3. pcreux commented on May 15, 2012

    @pcreux
    Contributor

    @fu-media It was closed because you didn't give any details. :)

  4. reopened this on May 15, 2012
  5. pcreux commented on May 15, 2012

    @pcreux
    Contributor

    Could you guys give a try to v0.4.4 with the latest version of inherited resources. This bug might come from inherited resources.

  6. elia commented on May 15, 2012

    @elia
    Member

    @pcreux I switched to head and application_controller remains cached, I'll try a bundle update inherited_resources and tell you what happens :)

  7. latortuga commented on May 15, 2012

    @latortuga
    Contributor

    I've been on 1.3.1 of InheritedResources (the latest) for quite awhile and have had this problem ever since forever. It's kind of annoying, especially since my CanCan current_ability method is inside the application controller. I think the helpers not being reloaded is a side-effect of the controller not being reloaded because helpers are all loaded from the application controller.

    I'm on AA 0.4.3, Rails 3.2.2, Ruby 1.9.3-p194 (latest I'm aware of).

  8. elia commented on May 15, 2012

    @elia
    Member

    @pcreux me too, on head activeadmin and latest inherited_resources I get cached application_controller methods

  9. pcreux commented on May 15, 2012

    @pcreux
    Contributor

    @gregbell was saying that the latest version of Inherited Resources would fix this issue in #342. Looks like he was wrong. :)

  10. pcreux commented on May 15, 2012

    @pcreux
    Contributor

    @fu-media I don't know why it's cached.

  11. jpmckinney commented on Jul 10, 2012

    @jpmckinney
    Contributor

    Experiencing this as well.

  12. ddidier commented on Nov 21, 2012

    @ddidier

    +1

  13. 18 remaining items

  14. seanlinsley commented on Feb 29, 2016

    @seanlinsley
    Contributor

    Disconnecting this from the Rails reloading, I can reproduce by simply calling ActiveAdmin.unload!

    ObjectSpace.each_object(ActiveAdmin::Resource).count => 17
    
    ActiveAdmin.unload!
    
    ObjectSpace.each_object(ActiveAdmin::Resource).count => 17
    ids = ObjectSpace.each_object(ActiveAdmin::Resource).map{ |r| r.controller.object_id }
    ids.count                                            => 17
    
    GC.start
    
    ObjectSpace.each_object(ActiveAdmin::Resource).count => 0
    ids.count{ |id| ObjectSpace._id2ref id rescue nil }  => 17
    ActiveAdmin::BaseController.descendants.count        => 22
    
    ObjectSpace._id2ref(ids.first).name.constantize
    -> NameError: uninitialized constant Admin::UsersController

    Unload currently does a lot of work to remove the objects from memory, but there must be a reference to the controller somewhere that's not being removed. If only Ruby made it easy to see the references keeping an object in memory...

  15. seanlinsley commented on Feb 29, 2016

    @seanlinsley
    Contributor

    Well the Mass gem isn't reporting any references.

    ids = ObjectSpace.each_object(ActiveAdmin::Resource).map{ |r| r.controller.object_id }
    Mass.references Mass[ids.first]
     => {"ActiveAdmin::Resource#70279696346980"=>["@controller"]} 
    
    ActiveAdmin.unload!
    
    Mass.references Mass[ids.first]
     => {}
  16. seanlinsley commented on Feb 29, 2016

    @seanlinsley
    Contributor

    This didn't seem to help:

    ActiveSupport::Dependencies.explicitly_unloadable_constants << 'ActiveAdmin::BaseController'
  17. glebtv commented on Sep 20, 2018

    @glebtv
    Contributor

    Might be related - rails code reloading becomes slower with each reload, when anything is present in app/admin folder

    To reproduce:

     100.times { puts Benchmark.measure { reload! } }
    

    For one app I have, with 100+ activeadmin modules, it is 2s for first reload, 4s for second, and up to 2-3 minutes to complete hang in 10-15 reloads.

  18. mvoropaiev commented on Mar 13, 2019

    @mvoropaiev

    @glebtv not sure if this is the right issue to report, but i am experiencing the same issue with AA 1.4.3, rails 5.2.2.
    Forced to re-start rails app after a few changes while developing admin part of application or otherwise it becomes unusable.
    Is there something that can be done to address it? Thanks.

  19. deivid-rodriguez commented on Mar 13, 2019

    @deivid-rodriguez
    Member

    No news here, but I've seen several development environment memory leaks fixed in Rails recently, so maybe Rails 6 brings new hope here.

    In particular, there's rails/rails#32892 and a related open PR. It'd be good if some hitting this problem could try that patch!

  20. mvoropaiev commented on Mar 26, 2019

    @mvoropaiev

    Trying a patch from merged PR https://github.com/rails/rails/pull/31442/files indeed increased reload speed of application, but now activeadmin does not reloads in dev env on files (app/admin/*) change, changes respected only after server restart, any idea where to dig regards this?
    Thanks!

  21. kaneru commented on Dec 18, 2019

    @kaneru

    Hello, everyone! Facing this issue in my project. Really need to DRY my code in some AA views with helpers. Is there any temporary hack for this issue? This hack seems not to work for me:

    To update your helpers automatically, you can temporary hack it like:

    Dir["#{ Rails.root }/app/helpers/*.rb"].each { |file| require file }
  22. sethdeckard commented on Aug 23, 2021

    @sethdeckard

    Given the age of this bug, I'm assuming this may not ever be fixed. What is a good alternative approach to using helpers in AA these days?

  23. ndbroadbent commented on Jul 15, 2022

    @ndbroadbent
    Contributor

    I just ran into this as well, and was wondering why I had to restart my server after any change in my helper file. I was just wondering if this is easier now with Zeitwerk and Rails 6 / Rails 7?

  24. rogerkk commented on Nov 2, 2022

    @rogerkk
    Contributor

    @ndbroadbent I still have to restart when i make changes to helpers, even under Zeitwerk on Rails 6.

  25. jcarlson commented on Aug 23, 2023

    @jcarlson

    Can this issue be reopened? This is still an issue with the following configuration:

    • Ruby 3.0.2
    • Rails 6.1.4
    • active admin 2.14.0
    • inherited_resources 1.13.1

    This issues is also mentioned in the "Gotchas" section of the docs which, by the way, are not linked from the table of contents.

  26. javierjulio commented on Dec 16, 2023

    @javierjulio
    Member

    The default branch is ready for a v4 release so I would be very open to these type of changes, I’m just not familiar with Rails autoloading to know what’s safe. I’ve been developing the new version of ActiveAdmin so I’ve experienced the pain of having to restart the dev server when making any changes. Since I've extracted partials I’ve had much better success. I would love to do the same with controllers or other files. If you’d like to help please let me know.

  27. jaynetics commented on Jun 17, 2024

    @jaynetics
    Contributor

    edit: in recent 4.0.0.beta versions this is fixed 🎉

    previous reply:

    putting this in an initializer is a bit hacky but does the trick as a workaround.

    Rails.application.reloader.to_prepare do
      Arbre.send(:remove_const, :Context)
      load $LOADED_FEATURES.grep(%r{/arbre/context\.rb}).sole
      Arbre::Context.prepend(MyHelper)
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions