我目前正在从我们的应用程序中删除IP日志记录,我想知道使用Devise进行此操作的最佳方法是什么?
答案 0 :(得分:1)
将此方法添加到用户模型可以让您选择跟踪的内容,在我的情况下,我在跟踪IP地址时有选择性:
def update_tracked_fields(request)
old_current = current_sign_in_at
new_current = Time.now.utc
self.last_sign_in_at = old_current || new_current
self.current_sign_in_at = new_current
if admin?
old_current = current_sign_in_ip
new_current = request.remote_ip
self.last_sign_in_ip = old_current || new_current
self.current_sign_in_ip = new_current
end
self.sign_in_count ||= 0
self.sign_in_count += 1
end