ensl.org/app/controllers/options_controller.rb

44 lines
797 B
Ruby
Raw Normal View History

class PollsController < ApplicationController
2014-03-31 21:33:16 +00:00
before_filter :get_poll, except: [:index, :new, :create]
respond_to :js
def add
end
def create
@poll = Poll.new params[:poll]
@poll.user = cuser
raise AccessError unless @poll.can_create? cuser
if @poll.save
flash[:notice] = t(:polls_create)
redirect_to @poll
else
2014-03-31 21:33:16 +00:00
render :new
end
end
def update
raise AccessError unless @poll.can_update? cuser
if @poll.update_attributes params[:poll]
flash[:notice] = t(:polls_update)
redirect_to @poll
else
2014-03-31 21:33:16 +00:00
render :edit
end
end
def destroy
raise AccessError unless @poll.can_destroy? cuser
@poll.destroy
redirect_to polls_url
end
private
def get_poll
@poll = Poll.find params[:id]
end
end