Sha256: a4f8dc822d66f9af808d5e2e3970a22c448210e554842c047127a3fbfbf155a0

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

module Sunspot
  module Rails
    class Railtie < ::Rails::Railtie
      initializer 'sunspot_rails.init', :before=> :load_config_initializers do
        Sunspot.session = Sunspot::Rails.build_session
        ActiveSupport.on_load(:active_record) do
          Sunspot::Adapters::InstanceAdapter.register(Sunspot::Rails::Adapters::ActiveRecordInstanceAdapter, ActiveRecord::Base)
          Sunspot::Adapters::DataAccessor.register(Sunspot::Rails::Adapters::ActiveRecordDataAccessor, ActiveRecord::Base)
          include(Sunspot::Rails::Searchable)
        end
        ActiveSupport.on_load(:action_controller) do
          include(Sunspot::Rails::RequestLifecycle)
        end
        require 'sunspot/rails/log_subscriber'
        RSolr::Connection.module_eval{ include Sunspot::Rails::SolrInstrumentation }
      end

      # Expose database runtime to controller for logging.
      initializer "sunspot_rails.log_runtime" do |app|
        require "sunspot/rails/railties/controller_runtime"
        ActiveSupport.on_load(:action_controller) do
          include Sunspot::Rails::Railties::ControllerRuntime
        end
      end

      rake_tasks do
        load 'sunspot/rails/tasks.rb'
      end
      
      generators do
        load "generators/sunspot_rails.rb"
      end
      
      # When loading console, make it output to STDERR.
      console do
        Sunspot::Rails::LogSubscriber.logger = Logger.new(STDERR)
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
sunspot_rails-2.0.0 lib/sunspot/rails/railtie.rb
sunspot_rails-2.0.0.pre.130115 lib/sunspot/rails/railtie.rb
sunspot_rails-2.0.0.pre.120925 lib/sunspot/rails/railtie.rb
sunspot_solr-2.0.0.pre.120924 sunspot_rails/lib/sunspot/rails/railtie.rb
sunspot_rails-2.0.0.pre.120924 sunspot_rails/lib/sunspot/rails/railtie.rb
sunspot-2.0.0.pre.120924 sunspot_rails/lib/sunspot/rails/railtie.rb