Skip to content

Instantly share code, notes, and snippets.

@DylanLacey
Created November 24, 2011 05:21
Show Gist options
  • Save DylanLacey/1390687 to your computer and use it in GitHub Desktop.
Save DylanLacey/1390687 to your computer and use it in GitHub Desktop.
class Waypoint < ActiveRecord::Base
belongs_to :address
belongs_to :job
# validates_presence_of :location_name, :if => proc { | wp | wp.friendly_name.nil? || (wp.friendly_name.blank? && wp.friendly_name.empty?)}
validates_presence_of :suburb_name
# Street is a composite class because that allows for .accessing
composed_of :street, :allow_nil => true, :mapping => [%w(street_number number), %w(street_name name), %w(designation_name type)]
def display_name
(friendly_name.presence || location_name) || "#{street_number} #{street_name} #{designation_name}, #{suburb_name}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment