diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/answer.rb | 6 | ||||
-rw-r--r-- | app/models/user.rb | 8 | ||||
-rw-r--r-- | app/views/answers/my_recruits.dryml | 2 | ||||
-rw-r--r-- | app/views/answers/my_recruits_cat.dryml | 2 |
4 files changed, 8 insertions, 10 deletions
diff --git a/app/models/answer.rb b/app/models/answer.rb index fd2781c..7830389 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -17,6 +17,12 @@ class Answer < ActiveRecord::Base belongs_to :question has_many :comments + named_scope :of_mentored_by, lambda { |mentor| { + :joins => :owner, :conditions => { 'users.mentor_id', mentor } } } + + named_scope :in_category, lambda { |category| { + :joins => :question, :conditions => { 'questions.question_category_id', category} } } + validates_uniqueness_of :question_id, :scope => :reference, :if => :reference validates_uniqueness_of :question_id, :scope => :owner_id, :unless => :reference diff --git a/app/models/user.rb b/app/models/user.rb index 26732fc..7b9c5f7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -102,14 +102,6 @@ class User < ActiveRecord::Base Question.unanswered_grouped(id) + Question.unanswered_ungrouped(id) end - def my_recruits_answers - Answer.all :joins => :owner, :conditions => ['users.mentor_id = ?', id] - end - - def my_recruits_answers_in_category(cat) - Answer.all :joins => [:question, :owner], :conditions => ['questions.question_category_id = ? AND users.mentor_id = ?', cat, id] - end - def answered_all_questions? Question.unanswered_grouped(id).count.zero? && Question.unanswered_ungrouped(id).count.zero? end diff --git a/app/views/answers/my_recruits.dryml b/app/views/answers/my_recruits.dryml index e61e4b6..6239d38 100644 --- a/app/views/answers/my_recruits.dryml +++ b/app/views/answers/my_recruits.dryml @@ -1,6 +1,6 @@ <index-page> <content:> - <repeat with="¤t_user.my_recruits_answers"> + <repeat with="&Answer.of_mentored_by(current_user)"> <card/> </repeat> </content:> diff --git a/app/views/answers/my_recruits_cat.dryml b/app/views/answers/my_recruits_cat.dryml index 8b2d4f3..e80297c 100644 --- a/app/views/answers/my_recruits_cat.dryml +++ b/app/views/answers/my_recruits_cat.dryml @@ -1,6 +1,6 @@ <index-page> <content:> - <repeat with="¤t_user.my_recruits_answers_in_category(params[:id])"> + <repeat with="&Answer.of_mentored_by(current_user).in_category(params[:id])"> <card/> </repeat> </content:> |