简体   繁体   中英

Identify keyword in active record query-rails

@zipcode = ZipCodes.identify(params[:zip_code])

I am new to rails. Can anyone tell me what does the keyword 'identify' do. Is this related to active record query?

Thank you in advance.

The gem zip-codes provides the ZipCodes class with a identify class method that simply reads a zip code and returns the state, city and timezone.

ZipCodes.identify('30301')
# => {:state_code=>"GA", :state_name=>"Georgia", :city=>"Atlanta", :time_zone=>"America/New_York"}

How do I/you know this? I guess you are new to the project where you saw this line:

  1. First look inside your project? Do you have a class called ZipCodes ? Yes, look in there.
  2. No, look into your Gemfile , do you have anything mentioning ZipCodes or similar? Yes, search for the gem documentation.
  3. No, Google a code snippet ZipCodes.identify and search among the results.

Here is the documentation for zip-codes : https://github.com/monterail/zip-codes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM