Reputation: 751
I want to set it up in a way that when a mobile phone uses my website, it will be redirected to a url with 'm' subdomain, but i will be using the same controllers, but just different views. I just need a general road map of how to implement something like that.
Upvotes: 0
Views: 149
Reputation: 388
For this you need to add a before filter in the application controller like
before_filter :detect_mobile_device
#Checking against the user agent
def detect_mobile_device
if request.user_agent =~ /Mobile|webOS/
redirect_to m.****.com
end
end
Then onwards you can modify and utilize it to render different views, you can also use
def is_mobile_device?
return request.user_agent =~ /Mobile|webOS/
end
For some browsers it might not work so you can use this gem
gem 'mobile-fu'
Upvotes: 1