polls_controller.rb

Tim Whelan, 2014-02-18 11:24

Download (800 Bytes)

 
1
class PollsController < ApplicationController
2
  unloadable
3

    
4
  # before_filter :find_project, :authorize, :only => :index
5
  # before_filter :find_project, :authorize, :only => :vote
6

    
7
  def index
8
    @project = Project.find(params[:project_id]) #comment out this line when using permissions
9
        @polls = Poll.find(:all)
10
  end
11

    
12
  def vote
13
    poll = Poll.find(params[:id])
14
    poll.vote(params[:answer])
15
    if poll.save
16
      flash[:notice] = 'Vote saved.'
17
    end
18
    redirect_to :action => 'index', :project_id => params[:project_id]
19
  end
20
  
21
  #end #possible location of definition end that broke voting when permissions enabled
22
  
23
  # private
24
  
25
  # def find_project
26
  # # @project variable must be set before calling the authorize filter
27
        # @project = Project.find(params[:project_id])
28
  # end
29
  
30
end