Project

General

Profile

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

Tam M, 2018-12-14 21:15

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

def index
@polls = Poll.all # @project.polls
end

def vote
poll = Poll.find(params[:id])
poll.vote(params[:answer])
if poll.save
flash[:notice] = 'Vote saved.'
end
redirect_to :action => 'index', :project_id => params[:project_id]
end

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