Closed levi-l-damian closed 5 years ago
Hi @levi-l-damian -
Please see this thread:
https://github.com/arvindvyas/Country-State-Select/issues/43
The official branch does not have Rails 5 support at this time, but I have a rails5 branch that you can use.
Rails 5 means Turbolinks 5, which means you need to add turbolinks:load
to the list of events that the various observers look for. You can replace page:change
with it, or just add it (space-separated) to the other events in your jQuery on()
calls.
@walterdavis - Good point.
I didn't notice that on my test application because I had turbolinks disabled for various reasons. (Turbolinks seems to break certain things for me.)
If anyone wants to use it with Rails 5 (without turbolinks, for the time being at least), you can use my fork: https://github.com/aldefouw/Country-State-Select
There are few extra things you'll have to do.
Add this to your appplication.js manifest
//= require country_state_select
Add this to your /config/routes.rb file:
mount CountryStateSelect::Rails::Engine, at: "/"
I am using my own fork of this project, which diverted from master.
If you have questions, I can try to answer them for you.
I added the gem to my Gemfile as recommended.
gem 'country_state_select'
I executed the bundle install / update commands and when attempting to restart the server I got this error as shown below. rails s /home/dell/.rvm/gems/ruby-2.3.4/gems/bundler-1.15.3/lib/bundler/runtime.rb:85:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'country_state_select'. (Bundler::GemRequireError) Gem Load Error is: Unsupported rails version Backtrace for gem load error is:
Do I need to explicitly call something on change of country to get related states?
Did you follow the directions on the README, particularly the part about "Required JavaScript"? Can you post a Gist of the rendered HTML where your pickers appear, or a link to the site in public? Your browser's Developer Tools will be able to tell you if you have a JavaScript error, which is what this sounds like (unless you didn't add the JS as directed).
added rails5/6 support in latest release
I added the gem to my Gemfile as recommended.
gem 'country_state_select'
I executed the bundle install / update commands and when attempting to restart the server I got this error as shown below.
rails s /Users/liviu-mac/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:89:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'country_state_select'. (Bundler::GemRequireError) Gem Load Error is: Unsupported rails version