carmen-ruby / carmen-rails

NOT ACTIVELY MAINTAINED Rails adapter for Carmen (provides country_select and subregion_select)
MIT License
215 stars 159 forks source link

undefined method `to_region_select_tag' #62

Open RashedKhalfan opened 7 years ago

RashedKhalfan commented 7 years ago

Dear all

I'm sorry if my error sound silly. I'm getting this error while implementing carmen on my rails app:

undefined methodto_region_select_tag' for # `

this is my form code ` <%= simple_form_for @practitioner do |f| %> <% if practitioner.errors.any? %>

<%= pluralize(practitioner.errors.count, "error") %> prohibited this practitioner from being saved:

    <% practitioner.errors.full_messages.each do |message| %>
  • <%= message %>
  • <% end %>

<% end %>

<%= f.label :firstName %> <%= f.text_field :firstName %>
<%= f.label :LastName %> <%= f.text_field :LastName %>
<%= f.label :contactNum %> <%= f.text_field :contactNum %>
<%= f.label :country %>
<%= f.country_select :country, priority: %w(US CA), prompt: 'Please select a country' %>
<%= f.label :state %> <%= f.text_field :state %>
<%= f.label :location %> <%= f.text_field :location %>
<%= f.submit %>

<% end %> `

Onikoroshi commented 7 years ago

Are you using Rails 5? I am upgrading my app to Rails 5.1 and I'm getting this same error ... :/

abrom commented 6 years ago

Hi @RashedKhalfan & @Onikoroshi

It looks like the maintainer is no longer maintaining the gem (as of 3 years ago). Unfortunately the gem also does not specify an incompatibility with Rails 5.

If you'd like, you're more than welcome to the patched version I've made. Just update your gemfile with:

gem 'carmen-rails', git: 'git@github.com:Studiosity/carmen-rails.git'

I'd suggest you take a look at the difference to understand why it didn't work:

https://github.com/carmen-ruby/carmen-rails/compare/master...Studiosity:master

The basic gist is that the to_region_select_tag method is defined based on the rails version (either 3 or 4). My change adds support for 5, as well as handling a deprecation of one of the internal helper methods

Enjoy

afelopez commented 5 years ago

@abrom I should have used; gem 'carmen-rails', :git => 'https://github.com/Studiosity/carmen-rails.git', :branch => 'master' to use it with heroku

abrom commented 4 years ago

FYI i've created a branch to also add support for Rails 6. I can't see any breaking changes from 5 to 6 so the update was pretty minimal.

https://github.com/Studiosity/carmen-rails/tree/rails-6

I'm going to continue testing and if everything looks good I'll merge it down to the master branch

milky-airi commented 1 year ago

@abrom Thank you very much!! I resolved the issue using your code:-D