Class: ActiveAdmin::Reloader::Rails32Reloader

Inherits:
AbstractReloader show all
Defined in:
lib/active_admin/reloader.rb

Overview

Reloads the application when using Rails 3.2

3.2 introduced a to_prepare block that only gets called when files have actually changed. ActiveAdmin had built this functionality in to speed up applications. So in Rails >= 3.2, we can now piggy back off the existing reloader. This simplifies our duties… which is nice.

Instance Attribute Summary

Attributes inherited from AbstractReloader

#active_admin_app, #rails_app, #rails_version

Instance Method Summary collapse

Methods inherited from AbstractReloader

#initialize, #major_rails_version, #reload!

Constructor Details

This class inherits a constructor from ActiveAdmin::Reloader::AbstractReloader

Instance Method Details

#attach!Object

Attach to Rails and perform the reload on each request.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/active_admin/reloader.rb', line 53

def attach!
  active_admin_app.load_paths.each do |path|
    rails_app.config.watchable_dirs[path] = [:rb]
  end

  reloader = self

  ActionDispatch::Reloader.to_prepare do
    reloader.reload!
  end
end