Reputation: 1111
How can I block access to Post/New page for mobile devices with Rails? Do I need some sort of JS redirection?
Thank you
Upvotes: 1
Views: 156
Reputation: 298
There is no truly safe way to block all mobile devices! You can check for the User-Agent in your controller and test if it's a mobile browser issuing the request. Check https://developer.mozilla.org/de/docs/Web/HTTP/Headers/User-Agent for a list of UAs.
def is_mobile?
request.user_agent == "mobile-ua-string"
end
Upvotes: 0