Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed is_tablet_device? to work with Ruby 1.9.3 #25

Merged
merged 1 commit into from

2 participants

@noctivityinc

Ruby 1.9.3 changed the handling of the =~ operator for regex so it returns a number instead of binary. I added !! to fix this issue.

@benlangfeld
Owner

Why did you re-order the methods? Makes the diff excessively complex.

@noctivityinc
@benlangfeld benlangfeld merged commit 1115f77 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 15, 2012
  1. @noctivityinc
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/mobile-fu.rb
View
12 lib/mobile-fu.rb
@@ -70,11 +70,11 @@ def has_mobile_fu(set_request_format = true)
# Add this to your controllers to prevent the mobile format from being set for specific actions
# class AwesomeController < ApplicationController
# has_no_mobile_fu_for :index
- #
+ #
# def index
# # Mobile format will not be set, even if user is on a mobile device
# end
- #
+ #
# def show
# # Mobile format will be set as normal here if user is on a mobile device
# end
@@ -139,12 +139,12 @@ def in_tablet_view?
# Returns either true or false depending on whether or not the user agent of
# the device making the request is matched to a device in our regex.
- def is_mobile_device?
- !is_tablet_device? && !!mobile_device
+ def is_tablet_device?
+ !!(request.user_agent.to_s.downcase =~ Regexp.new(ActionController::MobileFu::TABLET_USER_AGENTS))
end
- def is_tablet_device?
- request.user_agent.to_s.downcase =~ Regexp.new(ActionController::MobileFu::TABLET_USER_AGENTS)
+ def is_mobile_device?
+ !is_tablet_device? && !!mobile_device
end
def mobile_device
Something went wrong with that request. Please try again.