1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Add app/decorators in the host Rails application to Rails autoload paths. Describe the reasoning behind each hook/callback. -- Issue #32

This commit is contained in:
Ryan Cook 2012-05-09 09:59:22 -06:00
parent 6f731dcfb5
commit 8681058cf1

View file

@ -3,10 +3,28 @@ require 'rails/railtie'
module Draper
class Railtie < Rails::Railtie
##
# Decorators are loaded in
# => at app boot in non-development environments
# => after each request in the development environment
#
# This is necessary because we might never explicitly reference
# Decorator constants.
#
config.to_prepare do
::Draper::System.load_app_local_decorators
end
##
# The `app/decorators` path is eager loaded
#
# This is the standard "Rails Way" to add paths from which constants
# can be loaded.
#
config.before_initialize do |app|
app.config.paths.add 'app/decorators', :eager_load => true
end
initializer "draper.extend_action_controller_base" do |app|
ActiveSupport.on_load(:action_controller) do
Draper::System.setup(:action_controller)