akmur
akmur

Reputation: 1635

mobylette rails gem - detect iPad

I am using successfully the mobylette rails gem: https://github.com/tscolari/mobylette

I was wondering if anybody knows of how to disable the gem for iPads...

Thanks a bunch!

Alex

Upvotes: 1

Views: 865

Answers (2)

kelly
kelly

Reputation: 1

As per the docs:

If you need to exclude one or more user agents from the mobile format, lets say ipad for example, you may use the :skip_user_agents option:

mobylette_config do |config|
  config[:skip_user_agents] = [:ipad]
end

Upvotes: 0

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

Looks like the mobylette gem uses the code from mobile-fu (appears inactive, has issue #21 which is your problem).

The regex matches the iPad user agent on "mobile"

My suggestion -- override the is_mobile_request? controller method to:

#controllers/application_controller.rb
def is_mobile_request?
  return false if request.user_agent.to_s.downcase =~/ipad/
  request.user_agent.to_s.downcase =~ /#{MOBILE_USER_AGENTS}/
end

Upvotes: 3

Related Questions