Rails 3: How to store screen resolution?

天涯浪子 提交于 2019-12-08 05:15:55

问题


I want to store user's screen resolution in database when user login. How to detect and store it to database when user login?


回答1:


Read it with JavaScript (browsers don't send screen resolution information by default, so it isn't available to Ruby or anything else server side unless you make it so), then generate a hidden input, set the name and value based on the data you've gathered, then add it to the form containing the username and password inputs.

Oh, and you might find the window size more useful than the screen resolution. Not everybody maximizes their windows.



来源:https://stackoverflow.com/questions/4477648/rails-3-how-to-store-screen-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!