Sha256: 73686773f83ff78612676dd3ca65b528dff03aee17595906d7dba8c5583e2372
Contents?: true
Size: 1.28 KB
Versions: 7
Compression:
Stored size: 1.28 KB
Contents
module CanTango # Include helpers in the given scope to AC and AV. # "Borrowed" from devise def self.include_helpers(scope) # Seems like the order of initializers is important! ActiveRecord should go first! ActiveSupport.on_load(:active_record) do RailsAutoLoader.load_models! if CanTango.config.autoload.models? end ActiveSupport.on_load(:action_controller) do include scope::Rails::Helpers::ControllerHelper end ActiveSupport.on_load(:action_view) do include scope::Rails::Helpers::ViewHelper end end class RailsEngine < ::Rails::Engine initializer "cantango.helpers" do CanTango.include_helpers(CanTango) # load all models # this is needed in order to register all users and accounts with CanTango using the user/account macros! end config.to_prepare do # load all permits (development mode: EVERY request!) RailsAutoLoader.load_permits! if CanTango.config.autoload.permits? end end module RailsAutoLoader def self.load_models! load_files! :models end def self.load_permits! load_files! :permits end private def self.load_files! path Dir[::Rails.root + "app/#{path}/**/*.rb"].each do |path| require_dependency path end end end end
Version data entries
7 entries across 7 versions & 1 rubygems