创建新记录时是否可以获取用户的 Mac 地址? [英] Is it possible to get Mac Address of user's when creating new record?
本文介绍了创建新记录时是否可以获取用户的 Mac 地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以获取发布新记录的用户的 MAC 地址?
如果我有名为 mac_address
的列,我如何编写控制器以将 MAC 地址放入该列?
Is it possible to get the MAC address of a user that posts a new record?
If I had column called mac_address
, how can I write my controller to put the MAC address into that column?
推荐答案
用户的 mac 地址不是 Web 请求的一部分.
A user's mac address is not part of the web request.
我知道这不是您的问题,但您可以使用请求对象获取他们的 IP 地址:
I know it's not your question, but you can get their IP address using the request object:
request.ip
在您的 create
操作中,您可能有如下内容(假设您有一列 ip_address
):
In your create
action, you could have something like the following (assuming you have a column ip_address
):
def create
@item = Item.new(params[:item])
@item.ip_address = request.ip
if @item.save
...
end
end
这篇关于创建新记录时是否可以获取用户的 Mac 地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文