Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #5 from jaswope/master

Fix for Rails 3.1
  • Loading branch information...
commit 6927c6963d6ce17bec0f212a4f96ecb2809d6d59 2 parents 0b7418d + 77d0fc1
@benlangfeld benlangfeld authored
Showing with 21 additions and 5 deletions.
  1. +21 −5 lib/mobile-fu.rb
View
26 lib/mobile-fu.rb
@@ -8,13 +8,28 @@ class Railtie < Rails::Railtie
initializer "mobile-fu.configure" do |app|
app.config.middleware.use Rack::MobileDetect
end
+
+ if Rails::VERSION::MAJOR >= 3
+ initializer "mobile-fu.action_controller" do |app|
+ ActiveSupport.on_load :action_controller do
+ include ActionController::MobileFu
+ end
+ end
+
+ initializer "mobile-fu.action_view" do |app|
+ ActiveSupport.on_load :action_view do
+ include MobileFu::Helper
+ alias_method_chain :stylesheet_link_tag, :mobilization
+ end
+ end
+ end
+
Mime::Type.register_alias "text/html", :mobile
end
end
module ActionController
module MobileFu
-
def self.included(base)
base.extend ClassMethods
end
@@ -120,9 +135,10 @@ def mobile_exempt?
end
end
end
-
end
-ActionController::Base.send :include, ActionController::MobileFu
-ActionView::Base.send :include, MobileFu::Helper
-ActionView::Base.send :alias_method_chain, :stylesheet_link_tag, :mobilization
+if Rails::VERSION::MAJOR < 3
+ ActionController::Base.send :include, ActionController::MobileFu
+ ActionView::Base.send :include, MobileFu::Helper
+ ActionView::Base.send :alias_method_chain, :stylesheet_link_tag, :mobilization
+end
Please sign in to comment.
Something went wrong with that request. Please try again.