jeudi 4 juin 2015

Gecoder Add seperate values to Database for City State

using the geocoder gem

Can someone tell me can i get the City and State to automatically be entered into the database if i add those columns.

in the example below i am passing in :cs witch is an address

class Location < ActiveRecord::Base
  attr_accessible :cs, :latitude, :longitude
  geocoded_by :cs
  after_validation :geocode, :if => :cs_changed?
  has_many :shipments, :foreign_key => :origin_id
  has_many :shipments, :foreign_key => :dest_id
end

I need to save the geocoded city and state that was parsed.

either that or figure out how to get the gecoder to give me a list of locations in a particular group of states from the database

I would be passing in array [mo,il,ks,ar] or string "mo,il,ks,ar"

i have tried:

Location.near([mo,il,ks,ar])

I can however do:

Location.near("springfield, mo", 20)

Aucun commentaire:

Enregistrer un commentaire