Project

General

Profile

RE: Plugin tutorial - Pools from project menu - error aft... » polls_controller.rb

Tam M, 2018-12-14 21:15

 
1
class PollsController < ApplicationController
2
  before_filter :find_project, :authorize, :only => :index
3

    
4
  def index
5
    @polls = Poll.all # @project.polls
6
  end
7

    
8
  def vote
9
    poll = Poll.find(params[:id])
10
    poll.vote(params[:answer])
11
    if poll.save
12
      flash[:notice] = 'Vote saved.'
13
    end
14
    redirect_to :action => 'index', :project_id => params[:project_id]
15
  end
16

    
17
  private
18
  def find_project
19
    # @project variable must be set before calling the authorize filter
20
    @project = Project.find(params[:project_id])
21
  end
22
end
(2-2/2)