cities
cities copied to clipboard
Uninitialized constant Cities
I added "gem cities" into my Gemfile and bundled. I also downloaded the data. Then I opened my console and typed
2.1.1 :002 > require 'cities'
=> false
2.1.1 :003 > Cities
NameError: uninitialized constant Cities
Was I doing something wrong? I'm on rails 4.1.0 and I have also countries gem in my Gemfile. It is defined right before cities gem.
Hi, did you solve in the meantime? I'm having the same problem.
No, I fetched the data into a csv file and created my own class to use it.
~/Projects/cities master $ irb -rubygems -I lib
irb(main):001:0> require 'cities'
=> true
irb(main):002:0> Cities
=> Cities
irb(main):003:0>
If you added gem 'cities'
to your Gemfile, it should already be required when you start the Rails console. The Cities module did not exist prior to version 0.3.0 –what version are you both using?
I did have 0.1.0 which seems to be the newest version available through rubygems. Maybe installation from Github would have worked.
v0.3.0 has been available through Rubygems since April. Closing this ticket, try bundle update cities
.
I did bundle update cities
but it didn't update the gem from 0.1.0 to any newer version. Now it came into my mind that it might be a dependency issue. I tried to manually require version 0.3.0 and now bundler gives an error:
Bundler could not find compatible versions for gem "multi_json":
In Gemfile:
cities (= 0.3.0) ruby depends on
multi_json (~> 1.8.2) ruby
sass-rails (~> 4.0.0) ruby depends on
multi_json (1.10.0)
Could multi_json 1.10.0 be 'allowed' in the dependencies?
Ahhh, okay, that would make sense. Yep, I'll loosen the dependency and release a patch version later today.
Thanks!
Alright, Cities v0.3.1 is on Rubygems now. Should solve your dependency problem.