Created
July 28, 2013 18:13
-
-
Save biographie/6099495 to your computer and use it in GitHub Desktop.
This file contains 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
# == 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