cities icon indicating copy to clipboard operation
cities copied to clipboard

Uninitialized constant Cities

Open mmustala opened this issue 10 years ago • 9 comments

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.

mmustala avatar May 09 '14 19:05 mmustala

Hi, did you solve in the meantime? I'm having the same problem.

vitobotta avatar May 27 '14 13:05 vitobotta

No, I fetched the data into a csv file and created my own class to use it.

mmustala avatar May 27 '14 16:05 mmustala

~/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?

joecorcoran avatar May 27 '14 16:05 joecorcoran

I did have 0.1.0 which seems to be the newest version available through rubygems. Maybe installation from Github would have worked.

mmustala avatar May 28 '14 06:05 mmustala

v0.3.0 has been available through Rubygems since April. Closing this ticket, try bundle update cities.

joecorcoran avatar May 28 '14 07:05 joecorcoran

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?

mmustala avatar May 28 '14 07:05 mmustala

Ahhh, okay, that would make sense. Yep, I'll loosen the dependency and release a patch version later today.

joecorcoran avatar May 28 '14 07:05 joecorcoran

Thanks!

vitobotta avatar May 28 '14 07:05 vitobotta

Alright, Cities v0.3.1 is on Rubygems now. Should solve your dependency problem.

joecorcoran avatar May 28 '14 21:05 joecorcoran