From 11a98dce07124be18a6ca1062234dfabcde406bd Mon Sep 17 00:00:00 2001 From: kikito Date: Fri, 11 Nov 2016 19:10:36 +0100 Subject: [PATCH] Refactors in poll/question model --- app/models/poll/question.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index ae90ada12..d56990f17 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -9,6 +9,7 @@ class Poll::Question < ActiveRecord::Base has_many :comments, as: :commentable has_many :answers + has_many :partial_results has_and_belongs_to_many :geozones belongs_to :proposal @@ -21,7 +22,7 @@ class Poll::Question < ActiveRecord::Base validates :description, length: { maximum: Poll::Question.description_max_length } validates :question, length: { in: 10..Poll::Question.question_max_length } - scope :sort_for_list, -> { order('proposal_id IS NULL', :created_at)} + scope :sort_for_list, -> { order('poll_questions.proposal_id IS NULL', :created_at)} scope :for_render, -> { includes(:author, :proposal) } scope :by_geozone, -> (geozone_id) { joins(:geozones).where(geozones: {id: geozone_id}) }