To edit pages or tickets please login with username/password: aaf/aaf

Ticket #215: aaf_init.patch

File aaf_init.patch, 2.2 kB (added by aaf, 6 months ago)
  • acts_as_ferret/init.rb

    old new  
    2020 
    2121require 'acts_as_ferret' 
    2222 
     23config.after_initialize { ActsAsFerret::load_config } 
     24config.to_prepare       { ActsAsFerret::load_config } 
  • acts_as_ferret/lib/acts_as_ferret.rb

    old new  
    4646 
    4747require 'ferret_server' 
    4848 
    49 require 'aaf_loader' 
    5049require 'rdig_adapter' 
    5150 
    5251# The Rails ActiveRecord Ferret Mixin. 
     
    248247    return index 
    249248  end 
    250249 
    251   # call this in environment.rb in case you use external index declarations in 
    252   # config/aaf.rb: 
    253   # 
    254   #   Rails::Initializer.run do |config| 
    255   #     ... 
    256   #     config.after_initialize do 
    257   #       ActsAsFerret::initialize 
    258   #     end 
    259   #   end 
    260   # 
    261   def self.initialize 
    262     load_config 
    263     # let the application reload the aaf config on each request so aaf stays 
    264     # active even when classes are reloaded in dev mode. 
    265     if RAILS_ENV == 'development' 
    266       ActionController::Base.send :include, ActsAsFerret::AafLoader 
    267     end 
    268   end 
    269  
    270250  def self.load_config 
    271     # using require_dependency to make the reloading in dev mode via AafLoader working
     251    # using require_dependency to make the reloading in dev mode work
    272252    require_dependency "#{RAILS_ROOT}/config/aaf.rb" 
    273253    ActsAsFerret::logger.info "loaded configuration file aaf.rb" 
    274254  rescue LoadError 
  • /dev/null

    old new  
    1 # Helper to avoid class reloading issues when using shared index declarations 
    2 # outside of model classes (RAILS_ROOT/config/aaf.rb). 
    3 # 
    4 # Include this module in your ApplicationController to make sure your 
    5 # config/aaf.rb gets reloaded on every request in development mode. 
    6 # 
    7 module ActsAsFerret 
    8   module AafLoader 
    9     def self.included(target) 
    10       target.before_filter :load_aaf_config 
    11     end 
    12  
    13     def load_aaf_config 
    14       ActsAsFerret::load_config 
    15     end 
    16   end 
    17 end 

To edit pages or tickets please login with username/password: aaf/aaf