diff --git a/Gemfile b/Gemfile index c51812de..57a16ea7 100644 --- a/Gemfile +++ b/Gemfile @@ -98,7 +98,7 @@ gem 'aws-sdk-s3' # Talk to the catalog # Admin Dashboard gem 'activeadmin' gem 'mission_control-jobs' # Jobs dashboard -gem 'country_select' # , '~> 8.0' # 9.0 breaks active admin +gem 'country_select' # Graphql gem 'graphiql-rails' # , '1.8.0' # https://github.com/rmosolgo/graphiql-rails/issues/106 diff --git a/lib/monkeypatch.rb b/lib/monkeypatch.rb index 46778d48..c51b2a98 100644 --- a/lib/monkeypatch.rb +++ b/lib/monkeypatch.rb @@ -59,3 +59,28 @@ class RecordResponse < Base # Make zeitwork happy module Monkeypatch end + +# NOTE: Formtastic 5 doesn't support latest country_select gem +# https://github.com/formtastic/formtastic/issues/1381 +module Formtastic + module Inputs + class CountryInput + include Base + + CountrySelectPluginMissing = Class.new(StandardError) + + def to_html + raise CountrySelectPluginMissing, 'To use the :country input, please install a country_select plugin, like this one: https://github.com/stefanpenner/country_select' unless builder.respond_to?(:country_select) + + input_wrapping do + label_html << + builder.country_select(method, input_options.reverse_merge(priority_countries:), input_html_options) + end + end + + def priority_countries + options[:priority_countries] || builder.priority_countries + end + end + end +end