Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Doesn't work with country_select version 2.0.0+ #101

Open
pjg opened this issue Mar 13, 2014 · 5 comments
Open

Doesn't work with country_select version 2.0.0+ #101

pjg opened this issue Mar 13, 2014 · 5 comments

Comments

@pjg
Copy link

pjg commented Mar 13, 2014

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:

def country_select(method, options = {}, html_options = {})

(source)

Which is incompatible with formtastic-bootstrap's invocation:

builder.country_select(method, priority_countries, input_options, input_html_options)

(source)

The exact same issue is present on latest formtastic gem as well: formtastic/formtastic#1008

@pjg
Copy link
Author

pjg commented Mar 13, 2014

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).

@sodabrew
Copy link
Collaborator

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.

@jtomaszewski
Copy link
Collaborator

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?

@pjg
Copy link
Author

pjg commented Mar 13, 2014

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.

@sodabrew
Copy link
Collaborator

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants