Open pjg opened 10 years ago
The workaround is to put this into config/initializers/formtastic_bootstrap.rb
:
class FormtasticBootstrap::Inputs::CountryInput
def to_html
bootstrap_wrapping do
builder.country_select(method, input_options, form_control_input_html_options)
end
end
end
(BTW for formtastic-bootstrap version < 3.0.0 the last param should be called input_html_options
instead of form_control_input_html_options
).
Would you prefer if we force the newer version in our gem requirements, or is there a clean way to be compatible to both versions?
Monkey patching in an initializer is not an ideal long term solution.
We definitely should make it backward compatible.
We could base it on CountrySelect::VERSION.to_i >= 2
or on builder.method(:country_select).arity == 3
. What do you think?
country_select
is not in the gemspec (not here nor in the base formtastic gem), formtastic supports it only if the gem is installed (bundled). If it's not, it will raise but only when attempting to use the country
input type.
In other words, I think that it's necessary to be backwards compatible with the soon-to-be old version.
I'm perfectly fine with version constrains and different behaviour based on that.
Could you test this with the newly posted formtastic-bootstrap 3.1.0, which works with the new Formtastic class finder and let me know if it works / still broken?
country_select version 2.0.0 (not yet released) introduces a number of big changes. One among them is a different syntax for
country_select
view helper:(source)
Which is incompatible with formtastic-bootstrap's invocation:
(source)
The exact same issue is present on latest
formtastic
gem as well: https://github.com/justinfrench/formtastic/issues/1008