mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
allow Draper to support rails auto-loading -- Issue #32
This commit is contained in:
parent
b60d195ebd
commit
9dcb83cb66
2 changed files with 13 additions and 0 deletions
|
@ -3,6 +3,10 @@ require 'rails/railtie'
|
|||
module Draper
|
||||
class Railtie < Rails::Railtie
|
||||
|
||||
config.to_prepare do
|
||||
::Draper::System.load_app_local_decorators
|
||||
end
|
||||
|
||||
initializer "draper.extend_action_controller_base" do |app|
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
Draper::System.setup(:action_controller)
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
module Draper
|
||||
class System
|
||||
def self.app_local_decorator_glob
|
||||
'app/decorators/**/*_decorator.rb'
|
||||
end
|
||||
|
||||
def self.load_app_local_decorators
|
||||
decorator_files = Dir[ "#{ Rails.root }/#{ app_local_decorator_glob }" ]
|
||||
decorator_files.each { |d| load d }
|
||||
end
|
||||
|
||||
def self.setup(component)
|
||||
if component == :action_controller
|
||||
ActionController::Base.send(:include, Draper::ViewContextFilter)
|
||||
|
|
Loading…
Reference in a new issue