Fixed codeclimate issues

This commit is contained in:
Sergei Tsoganov 2023-05-15 14:23:41 +03:00
parent 0f16ec77f5
commit dc41cfb103
3 changed files with 11 additions and 10 deletions

View file

@ -40,8 +40,9 @@ module Admin
def edit; end
def show
@result = @registrar.send(params[:records]) unless params[:records].blank?
render_by_format('admin/registrars/show', "#{@registrar.name.parameterize}_#{params[:records]}")
method = params[:records].present? ? params[:records] : 'api_users'
@result = @registrar.send(method)
render_by_format('admin/registrars/show', "#{@registrar.name.parameterize}_#{method}")
end
def update

View file

@ -100,8 +100,7 @@ class ApiUser < User
active,
accredited?,
accreditation_expire_date,
created_at,
updated_at
created_at, updated_at,
]
end

View file

@ -13,6 +13,7 @@ class WhiteIp < ApplicationRecord
def validate_ipv4_and_ipv6
return if ipv4.present? || ipv6.present?
errors.add(:base, I18n.t(:ipv4_or_ipv6_must_be_present))
end
@ -32,12 +33,12 @@ class WhiteIp < ApplicationRecord
errors.add(:ipv6, :invalid)
end
API = 'api'
REGISTRAR = 'registrar'
INTERFACES = [API, REGISTRAR]
API = 'api'.freeze
REGISTRAR = 'registrar'.freeze
INTERFACES = [API, REGISTRAR].freeze
scope :api, -> { where("interfaces @> ?::varchar[]", "{#{API}}") }
scope :registrar_area, -> { where("interfaces @> ?::varchar[]", "{#{REGISTRAR}}") }
scope :api, -> { where('interfaces @> ?::varchar[]', "{#{API}}") }
scope :registrar_area, -> { where('interfaces @> ?::varchar[]', "{#{REGISTRAR}}") }
def interfaces=(interfaces)
super(interfaces.reject(&:blank?))
@ -84,7 +85,7 @@ class WhiteIp < ApplicationRecord
ipv6,
interfaces.join(', ').upcase,
created_at,
updated_at
updated_at,
]
end
end