mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Refactor deprecated in rails 6.1 issues
This commit is contained in:
parent
83f3e14330
commit
39bbe6e06d
10 changed files with 122 additions and 50 deletions
32
app/helpers/sorted_country_helper.rb
Normal file
32
app/helpers/sorted_country_helper.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module SortedCountryHelper
|
||||
def all_country_options(selected = nil)
|
||||
quick_options = options_for_select(quick_list, selected: selected)
|
||||
|
||||
# no double select
|
||||
selected = quick_list.map(&:second).include?(selected) ? '' : selected
|
||||
|
||||
all_options = options_for_select([['---', '---']] + all_sorted_truncated,
|
||||
selected: selected, disabled: ['---'])
|
||||
quick_options + all_options
|
||||
end
|
||||
|
||||
def quick_list
|
||||
[
|
||||
%w[Estonia EE],
|
||||
%w[Finland FI],
|
||||
%w[Latvia LV],
|
||||
%w[Lithuania LT],
|
||||
['Russian Federation', 'RU'],
|
||||
%w[Sweden SE],
|
||||
['United States', 'US'],
|
||||
]
|
||||
end
|
||||
|
||||
def all_sorted
|
||||
Country.all.sort_by(&:name)
|
||||
end
|
||||
|
||||
def all_sorted_truncated
|
||||
all_sorted.map { |country| [country.name.truncate(26), country.alpha2] }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue