#10 new
Tony

Mobile fu plus custom solution

Reported by Tony | January 10th, 2013 @ 08:51 AM

Hi,

Love your site. Question: Will mobile fu work with this solution?

class ApplicationController < ActionController::Base

protect_from_forgery

end

enable_mobile_fu

end

def check_for_mobile

session[:mobile_override] = params[:mobile] if params[:mobile]
prepare_for_mobile if mobile_device?

end

def prepare_for_mobile

prepend_view_path Rails.root + 'app' + 'views_mobile'

end

def mobile_device?

if session[:mobile_override]
  session[:mobile_override] == "1"
else
  # Season this regexp to taste. I prefer to treat iPad as non-mobile.
  (request.user_agent =~ /Mobile|webOS/) && (request.user_agent !~ /iPad/)
end

helper_method :mobile_device? end

Thanks,
Tony

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Want to automatically detect mobile devices that access your Rails application? Mobile Fu allows you to do just that. People can access your site from a Palm, Blackberry, iPhone, Nokia, etc. and it will automatically adjust the format of the request from :html to :mobile.

People watching this ticket

Pages