Created
November 24, 2011 05:21
-
-
Save DylanLacey/1390687 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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