Sha256: c15602403dc62eb309e42669194af973a42366b33597f1aea36e508be9aa6d6b

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require 'rails'
require 'sunrise-core'

module Sunrise
  class Engine < ::Rails::Engine
    config.before_initialize do
      ActiveSupport::XmlMini.backend = 'Nokogiri'
      InheritedResources.flash_keys = Sunrise.flash_keys
        
      config.i18n.load_path += Dir[File.join(File.dirname(__FILE__), "../../config", 'locales', '**', '*.{rb,yml}').to_s]
      
      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
      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
    
    # 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
      Paperclip.interpolates('basename') do |attachment, style|
        filename = attachment.original_filename.gsub(/#{File.extname(attachment.original_filename)}$/, "")
        Sunrise::Utils.parameterize_filename( filename )
      end
    end
    
    # For railties migrations rake
    def railtie_name
      'sunrise'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunrise-core-0.1.1 lib/sunrise/engine.rb
sunrise-core-0.1.0 lib/sunrise/engine.rb