What's the easiest way to detect the user's operating system in Rails 3?

前端 未结 4 1309
难免孤独
难免孤独 2021-02-07 20:01

Simple Rails app, mostly scaffolding. I want to detect whether the user is using Android or iPhone to access my app. What\'s the easiest way to do that?

4条回答
  •  野性不改
    2021-02-07 20:47

    if request.env['HTTP_USER_AGENT'].downcase.match(/android|iphone/)
      puts "yup, its mobile"
    end
    

提交回复
热议问题