thecodecrate / city-state

Simple ruby gem to create form lists with cities and states
MIT License
306 stars 135 forks source link

`CS.countries` is giving `undefined method 'exists?' for File:Class` error #61

Closed anmol-kumar0815 closed 1 year ago

anmol-kumar0815 commented 1 year ago

I have followed the following steps to install city-state:

  1. Added city-state in gem file.
  2. Run bundle install.

Then I tried to get the list of countries in rails console by:

CS.countries
Screenshot 2023-08-19 at 3 10 28 PM
anmol-kumar0815 commented 1 year ago

This issue occurs because I had installed 0.1.0 version in which exists? method has been used, and now this method has been depreciated.

To resolve this issue make sure you have installed 1.1.0 version. You can lock the gem version by adding the below line in your gem file:

gem "city-state", "1.1.0"
loureirorg commented 1 year ago

Good catch. Thanks, @anmol-kumar0815.

I restricted the version 0.x series to Ruby 2 only (release 0.1.1)

This guarantees that users using Ruby 3 and higher always use the latest 1.x series, even when not explicitly defining the version on Gemfile.