Sha256: 125669ea6f408661add4c14adffe4a7605ff70165cf9102e8c7a70e62af86353

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

# == Schema Information
#
# Table name: locations
#
#  id         :integer          not null, primary key
#  lat        :string(255)
#  lng        :string(255)
#  street     :string(255)
#  city       :string(255)
#  zip        :string(255)
#  region     :string(255)
#  country    :string(255)
#  created_at :datetime         not null
#  updated_at :datetime         not null
#  title      :string(255)
#

class Location < ActiveRecord::Base
  geocoded_by :complete_location, :latitude  => :lat, :longitude => :lng
  after_validation :geocode
  liquid_methods :street, :city, :zip, :region, :country, :title
  belongs_to :locateable, :polymorphic => true

  def complete_location
    result = ""
    result += "#{self.street}" if self.street.present?
    result += ", #{self.zip}" if self.zip.present?
    result += ", #{self.city}" if self.city.present?
  end

  def title
    self.complete_location
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rdcms-1.0.28 app/models/location.rb
rdcms-1.0.27 app/models/location.rb
rdcms-1.0.26 app/models/location.rb