README.md in jt-rails-address-1.0.1 vs README.md in jt-rails-address-1.1.0
- old
+ new
@@ -25,10 +25,11 @@
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
@@ -49,10 +50,11 @@
- `state_code`
- `country`
- `country_code`
- `lat`, GPS latitude
- `lng`, GPS longitude
+- `google_id`, Google Place Id
In your model:
```ruby
class User < ActiveRecord::Base
@@ -71,22 +73,24 @@
```html
<!-- Basic form, address is just a virtual field used for searching the address on Google Maps API -->
<%= form_for @user do |f| %>
<div class="jt-address-autocomplete">
+ <!-- This field is used to search the address on Google Maps -->
<%= f.text_field :address, class: 'jt-address-search' %>
+ <!-- All fields are hidden because the javascript will set their value automatically -->
<% for attr in JT::Rails::Address.fields %>
<%= f.hidden_field "address_#{attr}", class: "jt-address-field-#{attr}" %>
<% end %>
</div>
<%= f.submit %>
<% end %>
-<!-- Load Google Maps -->
+<!-- Load Google Maps and call googleMapInitialize when it's done -->
<script async type="text/javascript" src="//maps.googleapis.com/maps/api/js?libraries=places&callback=googleMapInitialize"></script>
```
In your `applicaton.js` you have to add:
```javascript
@@ -96,10 +100,10 @@
window.googleMapInitialize = function(){
// Simple usage
$('.jt-address-autocomplete').jt_address();
- // Advacned usage
+ // Advanced usage
$('.jt-address-autocomplete').jt_address({
types: ['geocode'],
componentRestrictions: { country: 'fr' }
});