Skip to content

Instantly share code, notes, and snippets.

@biographie
Created July 28, 2013 18:13
Show Gist options
  • Save biographie/6099495 to your computer and use it in GitHub Desktop.
Save biographie/6099495 to your computer and use it in GitHub Desktop.
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# title :text
# task_category_id :integer
# due_date :datetime
# description :text
# completed_at :datetime
# company_id :integer
# contact_id :integer
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Task < ActiveRecord::Base
attr_accessible :company_id, :completed_at, :contact_id, :description, :due_date, :task_category_id, :title, :user_id, :due_date_word
belongs_to :company
belongs_to :task_category
belongs_to :contact
belongs_to :user
before_save :check_due_date_word
attr_accessor :due_date_word
private
def check_due_date_word
case @due_date_word
when 'Today' then self.due_date = Time.now
when 'Tomorrow' then self.due_date = Time.now + 1.day
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment