Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fixed is_tablet_device? to work with Ruby 1.9.3 #25

Merged
merged 1 commit into from over 1 year ago

2 participants

noctivityinc Ben Langfeld
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.

Ben Langfeld
Owner

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

noctivityinc
Ben Langfeld benlangfeld merged commit 1115f77 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 15, 2012
noctivityinc noctivityinc fixed is_tablet_device method d159182
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. +6 6 lib/mobile-fu.rb
12 lib/mobile-fu.rb
@@ -70,11 +70,11 @@ def has_mobile_fu(set_request_format = true)
70 70 # Add this to your controllers to prevent the mobile format from being set for specific actions
71 71 # class AwesomeController < ApplicationController
72 72 # has_no_mobile_fu_for :index
73   - #
  73 + #
74 74 # def index
75 75 # # Mobile format will not be set, even if user is on a mobile device
76 76 # end
77   - #
  77 + #
78 78 # def show
79 79 # # Mobile format will be set as normal here if user is on a mobile device
80 80 # end
@@ -139,12 +139,12 @@ def in_tablet_view?
139 139 # Returns either true or false depending on whether or not the user agent of
140 140 # the device making the request is matched to a device in our regex.
141 141
142   - def is_mobile_device?
143   - !is_tablet_device? && !!mobile_device
  142 + def is_tablet_device?
  143 + !!(request.user_agent.to_s.downcase =~ Regexp.new(ActionController::MobileFu::TABLET_USER_AGENTS))
144 144 end
145 145
146   - def is_tablet_device?
147   - request.user_agent.to_s.downcase =~ Regexp.new(ActionController::MobileFu::TABLET_USER_AGENTS)
  146 + def is_mobile_device?
  147 + !is_tablet_device? && !!mobile_device
148 148 end
149 149
150 150 def mobile_device

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.