Sha256: c8c31af85d8c65ad380520c1960ff21abeb652ecc1a69b150b7a2ce0c58ec36d

Contents?: true

Size: 893 Bytes

Versions: 21

Compression:

Stored size: 893 Bytes

Contents

require 'geocoder'

class Venue < ActiveRecord::Base
  belongs_to :organization
  belongs_to :event
 
  validates_presence_of :name
  
  attr_accessible :name, :address1, :address2, :city, :state, :zip, :time_zone

  geocoded_by :geocode_address, :latitude => :lat, :longitude => :long

  before_save :geocode, :if => :address1_changed?
  
  def address_as_string
    street_as_string + " " + city_state_zip_as_string
  end

  def street_as_string
    str = (address1 || "") + " " + (address2 || "")
    str.strip
  end
  
  def city_state_zip_as_string
    str = (city || "") + " " + (state || "") + " " + (zip || "")
    str.strip
  end
  
  def address_as_url_query
    URI::escape(street_as_string + " " + city_state_zip_as_string)
  end

  def geocode_address
    (address1 || "") + ", " + (address2 || "") + ", " + (city || "") +
      ", " + (state || "") + " " + (zip || "")
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.23 app/models/venue.rb
artfully_ose-1.2.0.pre.21 app/models/venue.rb
artfully_ose-1.2.0.pre.20 app/models/venue.rb
artfully_ose-1.2.0.pre.19 app/models/venue.rb
artfully_ose-1.2.0.pre.18 app/models/venue.rb
artfully_ose-1.2.0.pre.17 app/models/venue.rb
artfully_ose-1.2.0.pre.16 app/models/venue.rb
artfully_ose-1.2.0.pre.15 app/models/venue.rb
artfully_ose-1.2.0.pre.12 app/models/venue.rb
artfully_ose-1.2.0.pre.11 app/models/venue.rb
artfully_ose-1.2.0.pre.10 app/models/venue.rb
artfully_ose-1.2.0.pre.9 app/models/venue.rb
artfully_ose-1.2.0.pre.8 app/models/venue.rb
artfully_ose-1.2.0.pre.7 app/models/venue.rb
artfully_ose-1.2.0.pre.6 app/models/venue.rb
artfully_ose-1.2.0.pre.5 app/models/venue.rb
artfully_ose-1.2.0.pre.4 app/models/venue.rb
artfully_ose-1.2.0.pre.3 app/models/venue.rb
artfully_ose-1.2.0.pre.2 app/models/venue.rb
artfully_ose-1.2.0.pre.1 app/models/venue.rb