Add by_latest_used
scope, move admin area recent IPs to partial (#29497)
This commit is contained in:
parent
c70c39cad0
commit
f56309f5f0
@ -15,4 +15,6 @@ class UserIp < ApplicationRecord
|
||||
self.primary_key = :user_id
|
||||
|
||||
belongs_to :user
|
||||
|
||||
scope :by_latest_used, -> { order(used_at: :desc) }
|
||||
end
|
||||
|
@ -62,13 +62,7 @@
|
||||
%td
|
||||
%time.formatted{ datetime: account.created_at.iso8601, title: l(account.created_at) }= l account.created_at
|
||||
%td
|
||||
- recent_ips = account.user.ips.order(used_at: :desc).to_a
|
||||
- recent_ips.each_with_index do |recent_ip, i|
|
||||
%tr
|
||||
- if i.zero?
|
||||
%th{ rowspan: recent_ips.size }= t('admin.accounts.most_recent_ip')
|
||||
%td= recent_ip.ip
|
||||
%td= table_link_to 'search', t('admin.accounts.search_same_ip'), admin_accounts_path(ip: recent_ip.ip)
|
||||
= render partial: 'admin/accounts/user_ip', collection: account.user.ips.by_latest_used
|
||||
%tr
|
||||
%th= t('admin.accounts.most_recent_activity')
|
||||
%td
|
||||
|
5
app/views/admin/accounts/_user_ip.html.haml
Normal file
5
app/views/admin/accounts/_user_ip.html.haml
Normal file
@ -0,0 +1,5 @@
|
||||
%tr
|
||||
- if user_ip_iteration.first?
|
||||
%th{ rowspan: user_ip_iteration.size }= t('admin.accounts.most_recent_ip')
|
||||
%td= user_ip.ip
|
||||
%td= table_link_to 'search', t('admin.accounts.search_same_ip'), admin_accounts_path(ip: user_ip.ip)
|
Loading…
Reference in New Issue
Block a user