Sha256: c9f2a55d319d5f23b3244ea068221309b668f4e4be0f92e3fa3fe70ad3ec8852

Contents?: true

Size: 1.8 KB

Versions: 6

Compression:

Stored size: 1.8 KB

Contents

require "rails"
require "action_view"

require 'jquery-rails'

require 'rails_connector/configuration'

module ::RailsConnector
  class Engine < Rails::Engine
    config.to_prepare { RailsConnector::Configuration.to_prepare }
    config.after_initialize { RailsConnector::Configuration.after_initialize }

    # make sure our exceptions cause an adequate error page and http status code
    config.action_dispatch.rescue_responses.merge!("RailsConnector::ResourceNotFound" => :not_found)

    initializer "rails_connector.add_cms_routing_paths", :after => :add_routing_paths do |app|
      cms_route = File.expand_path("cms_routes.rb", paths['config'].to_a.first)
      app.routes_reloader.paths.push(cms_route)
    end

    # Expose rails connector runtime to controller for logging.
    initializer "rails_connector.log_runtime" do |app|
      runtime =
        begin
          RailsConnector::ControllerRuntime
        rescue NameError
          nil
        end

      if runtime
        RailsConnector::LogSubscriber.attach_to :rails_connector
        ActiveSupport.on_load(:action_controller) do
          include runtime
        end
      end
    end

    initializer "rails_connector.configure_database", :before => :load_config_initializers do |app|
      RailsConnector::Configuration.configure_cms_database
    end

    initializer "rails_connector.routing_helpers" do
      if Rails.env == 'test'
        ActionDispatch::TestRequest.__send__(:include, RailsConnector::CmsTestRequest)
      end

      ActionController::Base.__send__(:include, CmsRoutingHelper)
      ActionView::Base.__send__(:include, CmsRoutingHelper)
    end

    config.autoload_paths += paths['lib'].to_a
    config.autoload_once_paths += paths['lib'].to_a

    RailsConnector.rack_middlewares.each { |middleware| config.app_middleware.use middleware }
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
infopark_cloud_connector-7.0.1 lib/rails_connector/engine.rb
infopark_cloud_connector-7.0.0 lib/rails_connector/engine.rb
infopark_cloud_connector-6.9.5 lib/rails_connector/engine.rb
infopark_rails_connector-6.9.4 lib/rails_connector/engine.rb
infopark_rails_connector-6.9.3.1.36404185 lib/rails_connector/engine.rb
infopark_rails_connector-6.9.2.1.125136549 lib/rails_connector/engine.rb