Skip to content

Instantly share code, notes, and snippets.

@sllvn
Last active December 12, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sllvn/4692981 to your computer and use it in GitHub Desktop.
Save sllvn/4692981 to your computer and use it in GitHub Desktop.
class Contract < ActiveRecord::Base
belongs_to :contract_type
has_many :contract_terms
def display_name
"#{self.contract_type.name}: #{self.person_name}"
end
def person_name
# todo: this seems inefficient, do we want to throw important metadata in the
# contract record itself rather than extract from terms each time?
name = self.contract_terms.find { |t| t.field == "Performer" }.value
name = "N/A" if name == ""
name
end
def display_date
self.date_created.strftime("%Y-%m-%d")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment