mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
e59e8ac8e7
- Add .params to models and update controllers - Add afk time to gather - Reannotate models - Fix rspec problem by using latest rspec plugins from github
43 lines
825 B
Ruby
43 lines
825 B
Ruby
class PollsController < ApplicationController
|
|
before_action :get_poll, except: [:index, :new, :create]
|
|
respond_to :js
|
|
|
|
def add
|
|
end
|
|
|
|
def create
|
|
@poll = Poll.new(Poll.params(params, cuser))
|
|
@poll.user = cuser
|
|
raise AccessError unless @poll.can_create? cuser
|
|
|
|
if @poll.save
|
|
flash[:notice] = t(:polls_create)
|
|
redirect_to @poll
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def update
|
|
raise AccessError unless @poll.can_update? cuser
|
|
|
|
if @poll.update_attributes(Poll.params(params, cuser))
|
|
flash[:notice] = t(:polls_update)
|
|
redirect_to @poll
|
|
else
|
|
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
|