# JTRailsAddress [![Gem Version](https://badge.fury.io/rb/jt-rails-address.svg)](http://badge.fury.io/rb/jt-rails-address) JTRailsAddress simplify postal addresses management and geocoding with Google Maps API in Ruby On Rails and Javascript. ## Installation JTRailsAddress is distributed as a gem, which is how it should be used in your app. Include the gem in your Gemfile: gem 'jt-rails-address', '~> 1.0' ## Usage ### Basic usage In your migration file: ```ruby class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :username, null: false t.string :email, null: false t.string :password_digest # Each field will be prefixed by 'address_' t.address :address t.timestamps null: false end end end ``` It will create all the fields you need for address management: - `formatted_address`, "Empire State Building, 350 5th Ave, New York, NY 10118" - `street_number`, "350" - `street_name`, "5th Ave" - `street`, "350 5th Ave", it's a concatenation of `street_number` and `street_name` - `city` - `zip_code` - `department` - `department_code` - `state` - `state_code` - `country` - `country_code` - `lat`, GPS latitude - `lng`, GPS longitude In your model: ```ruby class User < ActiveRecord::Base # Add a virtual field named `address` and a class method `address_fields` returning `JT::Rails::Address.fields` prefixed by `address_` in this case has_address :address end ``` ### Javascript usage with Google Maps API You probably want to use an autocompletion service like Google Maps API. In your HTML: ```html <%= form_for @user do |f| %>