From 340219284a504d6fc2e405fd0023d6c4d7e7482e Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 16 Nov 2024 09:49:09 -0500 Subject: [PATCH] Add `ip_blocks_expires_options` helper method for collection options --- app/helpers/admin/ip_blocks_helper.rb | 4 ++++ app/views/admin/ip_blocks/new.html.haml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/admin/ip_blocks_helper.rb b/app/helpers/admin/ip_blocks_helper.rb index 4aae3aae7a..0202e80f02 100644 --- a/app/helpers/admin/ip_blocks_helper.rb +++ b/app/helpers/admin/ip_blocks_helper.rb @@ -9,4 +9,8 @@ module Admin::IpBlocksHelper ] ) end + + def ip_blocks_expires_options + [1.day, 2.weeks, 1.month, 6.months, 1.year, 3.years] + end end diff --git a/app/views/admin/ip_blocks/new.html.haml b/app/views/admin/ip_blocks/new.html.haml index 81493012c6..8a52bbf95e 100644 --- a/app/views/admin/ip_blocks/new.html.haml +++ b/app/views/admin/ip_blocks/new.html.haml @@ -12,7 +12,7 @@ .fields-group = f.input :expires_in, - collection: [1.day, 2.weeks, 1.month, 6.months, 1.year, 3.years].map(&:to_i), + collection: ip_blocks_expires_options.map(&:to_i), label_method: ->(i) { I18n.t("admin.ip_blocks.expires_in.#{i}") }, prompt: I18n.t('invites.expires_in_prompt'), wrapper: :with_block_label