Sha256: 309ed1c9af38b08814eb0e80dcc02bb5f0ba1c645bda857578c155c3df301eb8

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

require 'rails'
require 'awesome_nested_set'
require 'inherited_resources'
require 'sunrise-core'
require 'sunrise-file-upload'
require "carrierwave"

module Sunrise
  class Engine < ::Rails::Engine
    config.i18n.load_path += Dir[File.join(File.dirname(__FILE__), "../../config", 'locales', '**', '*.{rb,yml}').to_s]
    config.autoload_paths << File.expand_path("../../../app/sweepers", __FILE__)
    
    initializer "sunrise.core.setup" do
      ActiveSupport::XmlMini.backend = 'Nokogiri'
      InheritedResources.flash_keys = Sunrise.flash_keys
        
      I18n.backend = Sunrise::Utils::I18nBackend.new
      
      ActiveSupport.on_load :active_record do
        ActiveRecord::Base.send :include, Sunrise::Utils::Mysql
        ActiveRecord::Base.send :include, Sunrise::Utils::AccessibleAttributes
        ActiveRecord::Base.send :include, Sunrise::CarrierWave::Glue
      end
      
      ActiveSupport.on_load :action_controller do
        ActionController::Base.send :include, Sunrise::Controllers::HeadOptions
      end
      
      ActiveSupport.on_load :action_view do
        ActionView::Base.send :include, Sunrise::Views::Helpers
      end
    end
    
    initializer "sunrise.core.awesome_nested_set" do
      CollectiveIdea::Acts::NestedSet::Model.send :include, Sunrise::NestedSet::Depth
      CollectiveIdea::Acts::NestedSet::Model::InstanceMethods.send :include, Sunrise::NestedSet::Descendants
    end
    
    # Wrap errors in ul->li list and skip labels.
    config.to_prepare do
      ActionView::Base.field_error_proc = Sunrise.field_error_proc
    end
    
    config.after_initialize do
      Sunrise::FileUpload::Manager.before_create do |env, asset|
        asset.user = env['warden'].user if env['warden']
      end
    end
    
    # For railties migrations rake
    def railtie_name
      'sunrise'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunrise-core-0.2.2 lib/sunrise/engine.rb
sunrise-core-0.2.1 lib/sunrise/engine.rb
sunrise-core-0.2.0 lib/sunrise/engine.rb