You can do it that way by defining a function like below:
def mobile_device?
if session[:mobile_param]
session[:mobile_param] == "1"
else
request.user_agent =~ /Mobile|webOS/
end
end
Or you can use gems to detect mobile devices like
- https://github.com/tscolari/mobylette
- https://github.com/shenoudab/active_device