adds assigned_polls method to poll_officer

This commit is contained in:
Juanjo Bazán
2017-01-02 20:28:16 +01:00
parent 55fea6c037
commit b3fd7ffafa
2 changed files with 54 additions and 0 deletions

View File

@@ -6,5 +6,12 @@ class Poll
validates :user_id, presence: true, uniqueness: true
delegate :name, :email, to: :user
def assigned_polls
officer_assignments.includes(booth_assignment: :poll).
map(&:booth_assignment).
map(&:poll).uniq.compact.
sort {|x, y| y.ends_at <=> x.ends_at}
end
end
end