Permalink
Browse files

writing methods in model user

- taught_lessons
- upcoming_teacher_lessons
- trained_lessons
- upcoming_student_lessons
  • Loading branch information...
1 parent 96ab6e4 commit c161a4c0761fa91c70db31c97caf59c8415e1f1b @abaranov abaranov committed Jun 21, 2012
Showing with 4 additions and 8 deletions.
  1. +4 −8 app/models/user.rb
View
@@ -28,23 +28,19 @@ class User < ActiveRecord::Base
has_many :student_lessons, through: :shares, source: :lesson, conditions: { shares: { share_type: 'study' } }
def taught_lessons
- # TODO
- # returns teacher_lessons where lessons.updated_at < NOW()
+ self.teacher_lessons.where("lessons.updated_at < ?", Time.now)
end
def upcoming_teacher_lessons
- # TODO
- # returns teacher_lessons where lessons.updated_at > NOW()
+ self.teacher_lessons.where("lessons.updated_at > ?", Time.now)
end
def trained_lessons
- # TODO
- # returns student_lessons where lessons.updated_at < NOW()
+ self.student_lessons.where("lessons.updated_at < ?", Time.now)
end
def upcoming_student_lessons
- # TODO
- # returns student_lessons where lessons.updated_at > NOW()
+ self.student_lessons.where("lessons.updated_at > ?", Time.now)
end
end

0 comments on commit c161a4c

Please sign in to comment.