mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Geocoded Spree addresses
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -31,6 +31,7 @@ gem 'oj'
|
||||
gem 'chili', :github => 'eaterprises/chili'
|
||||
gem 'deface', :github => 'spree/deface'
|
||||
gem 'paperclip'
|
||||
gem 'geocoder'
|
||||
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
|
||||
@@ -263,6 +263,7 @@ GEM
|
||||
ruby-hmac
|
||||
formatador (0.2.4)
|
||||
fssm (0.2.10)
|
||||
geocoder (1.1.8)
|
||||
haml (3.1.6)
|
||||
highline (1.6.18)
|
||||
hike (1.2.3)
|
||||
@@ -463,6 +464,7 @@ DEPENDENCIES
|
||||
enterprises_distributor_info_rich_text_feature!
|
||||
factory_girl_rails
|
||||
faker
|
||||
geocoder
|
||||
haml
|
||||
jquery-rails
|
||||
letter_opener
|
||||
|
||||
10
app/models/spree/address_decorator.rb
Normal file
10
app/models/spree/address_decorator.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
Spree::Address.class_eval do
|
||||
geocoded_by :full_address
|
||||
after_validation :geocode
|
||||
|
||||
def full_address
|
||||
full_address = [address1, address2, zipcode, city, country.name, state.name]
|
||||
filtered_address = full_address.select{ |field| !field.nil? && field != '' }
|
||||
filtered_address.compact.join(', ')
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddLatitudeAndLongitudeToAddresses < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :spree_addresses, :latitude, :float
|
||||
add_column :spree_addresses, :longitude, :float
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130806055125) do
|
||||
ActiveRecord::Schema.define(:version => 20130807002915) do
|
||||
|
||||
create_table "cms_blocks", :force => true do |t|
|
||||
t.integer "page_id", :null => false
|
||||
@@ -252,6 +252,8 @@ ActiveRecord::Schema.define(:version => 20130806055125) do
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "company"
|
||||
t.float "latitude"
|
||||
t.float "longitude"
|
||||
end
|
||||
|
||||
add_index "spree_addresses", ["firstname"], :name => "index_addresses_on_firstname"
|
||||
|
||||
Reference in New Issue
Block a user