diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 0c802e17f..f6f155106 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -7,7 +7,7 @@ class PollsController < ApplicationController end def show - + @questions = @poll.questions.sort_for_list.for_render end end diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index 75f78fb15..59ff11a70 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -23,6 +23,7 @@ class Poll::Question < ActiveRecord::Base scope :sort_for_list, -> { order('proposal_id IS NULL', :created_at)} scope :for_render, -> { includes(:author, :proposal) } + scope :by_geozone, -> (geozone_id) { joins(:geozones).where(geozones: {id: geozone_id}) } def description super.try :html_safe @@ -45,4 +46,6 @@ class Poll::Question < ActiveRecord::Base end end + + end diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index e9eeb7ca2..71870cedf 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -1,5 +1,10 @@ <%= @poll.name %> -<%= @poll.questions.sort_for_list.each do |question| %> - <%= question.title %> +<% @questions.each do |question| %> +