Closed aldefouw closed 4 years ago
Not for me. Am running Rails 5 and although I followed the instructions above, as well as trying gem 'country_state_select', '3.0.0' (as well as '3.0.1' and '3.0.2'), I continue to experience issues with versions of rack, railties and sprockets, when I run bundle update. Big fail, but hope you can get all the dependencies sorted.
@Atrain2020 I made a development branch that works in Rails 5.
Use at your own risk (as with any gem I suppose), but I am using it in production on a site right now until a version with the Rails 5 change is merged into master on arvindvyas' master branch.
(Using the gem on my hobby project: http://pistonrepublic.com/)
Here's the branch: https://github.com/aldefouw/Country-State-Select/tree/alcd-development
I agree this gem needs a lot of dependencies fixed up.
This was the first gem I ever worked on ... the dependencies probably would be better with >= instead of ~> in the version dependencies in the gemspec.
I have been trying to find time to fix some of this stuff, but I've simply been too busy at my "day" job. Several 10 or 12 hour days lately and my commuting time is over 2 hours. Doesn't leave much time for anything outside of just living =).
Hey aldefouw, thanks for the quick response. Will have a go with the branch. Appreciate the effort.
One other thing to keep in mind is that my branch is an older version of the gem. It does not include the cities data.
Ok, no problem. Thanks :-)
@aldefouw I am using your Rails 5 branch on a new project. I encountered a 404 error on the POST to /find_states in the browser console whenever I selected a country, along with no change in the state field.
I was able to resolve this by changing routes.rb from its current state back to what we see here:
Rails.application.routes.draw do
scope :module => "country_state_select" do
post 'find_states' => 'cscs#find_states'
end
end
Hi @elliottbernstein. Thanks for the note.
Are you interested in doing a pull request on my branch to fix the code?
@elliottbernstein - The reason that you were seeing that issue with my branch is because you weren't mounting the routes.
You can use my branch and mount the routes like so:
mount CountryStateSelect::Rails::Engine, at: "/"
@aldefouw - where do I put that line - I tried putting it in my applications routes.rb but it fails whereas the recommendation from @elliottbernstein works when I put it in my apps routes.rb
p.s. I am on Rails 4.2 but getting same error as elliot
@ryan2johnson9 - Mounting the routes only works if you are on my branch: https://github.com/aldefouw/Country-State-Select/tree/alcd-development
If you are on arvindvyas' branch, it will not work.
The code in my routes.rb file looks like this:
CountryStateSelect::Rails::Engine.routes.draw do scope :module => "country_state_select" do post 'find_states' => 'cscs#find_states' post 'find_cities' => 'cscs#find_cities' end end
The code in arvindvyas' branch is like this:
Rails.application.routes.draw do scope :module => "country_state_select" do post 'find_states' => 'cscs#find_states' post 'find_cities' => 'cscs#find_cities' end end
As you can see, it's isolating the routes to the engine rather than the rails application in my code.
To use my branch, add this:
@gem "country_state_select", "~> 3.1", :github => 'aldefouw/Country-State-Select', :branch => 'alcd-development'
You add the mount code to routes.rb in your application:
mount CountryStateSelect::Rails::Engine, at: "/"
(It's worth noting that you can actually mount the routes to whatever path you'd like.)
Hope that helps!
find_states call returns data like
{"cscs":[["AZ","Abu Dhabi"],["DU","Dubai"],["FU","Al Fujayrah"],["RK","Ra's al Khaymah"],["SH","Ash Shariqah"]]}
but you are looping on data insetad of data.cscs
May be city-state gem, from where data is used has changed a bit
I had to fork to make some changes, now its working fine on local but giving permission issue of city-state on server. any help?
I am using this gem , but when i calls find_states and find_cities it results json as a single array like this [["AN","Union Territory of Andaman and Nicobar Islands"],["AP","Andhra Pradesh"],["AR","Arunachal Pradesh"],["AS","Assam"],["BR","Bihar"],["CH","Chandigarh"],["CT","State of Chhattisgarh"]] , but i want it to be described like this if states means: {states:[["AN","Union Territory of Andaman and Nicobar Islands"],["AP","Andhra Pradesh"],["AR","Arunachal Pradesh"],["AS","Assam"],["BR","Bihar"],["CH","Chandigarh"],["CT","State of Chhattisgarh"]]}. and if it results cities means {cities:[[cities array]]}. please give a solution.
The gem seems to work fine with Rails 5. You just need to add this line to the 'country_state_select.rb' file in the /lib/ directory:
Should be a pretty easy add.
I also had to change this runtime dependency:
spec.add_runtime_dependency 'compass-rails', '>= 2.0.4'