Sha256: 8b771f6164ef5ab870bf370e65d35a074f01dde419000b221ee0293363c30bc2

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require "mobile_enhancements/route_helpers"
require "mobile_enhancements/helper_delegation"
require "mobile_enhancements/url_helper"
require "rails/railtie"

module MobileEnhancements
  class Railtie < Rails::Railtie

    config.after_initialize do
      # setup our route helpers
      ActionDispatch::Routing::Mapper.send(:include, MobileEnhancements::RouteHelpers)
      # setup the path helpers
      ActionController::Base.send(:include, MobileEnhancements::HelperDelegation)
      # setup the layout calculation
      ActionController::Base.layout :determine_layout
      # include the UrlHelper into action view
      ActionView::Base.send(:include, UrlHelper)
      # if we have a custom mobile format
      if format = MobileEnhancements.configuration.mobile_format
        # register it as an alias to the HTML mime-type
        Mime::Type.register_alias "text/html", format
        # setup the format calculation
        ActionController::Base.class_eval do
          before_filter do |controller|
            controller.request.format = controller.determine_format
            controller.params["mobile"] = controller.mobile_param_value
          end
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mobile-enhancements-0.0.5 lib/mobile_enhancements/railtie.rb