Class: PollingController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PollingController
- Includes:
- Cms::Authentication::Controller, Cms::PollsHelper
- Defined in:
- app/controllers/polling_controller.rb
Overview
Handles the public submissions of answers to poll questions.
Instance Method Summary collapse
Instance Method Details
#reset ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/polling_controller.rb', line 31 def reset @poll = Poll.find(params[:id]) = (@poll) .delete() redirect_to "/" end |
#results ⇒ Object
26 27 28 29 |
# File 'app/controllers/polling_controller.rb', line 26 def results @poll = Poll.find(params[:id]) render :layout => false end |
#update ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/polling_controller.rb', line 6 def update @response = PollResponse.find(params[:id]) unique_key = (@response.poll) if ![unique_key] @response.votes += 1 @response.save! [unique_key] = { :value => true, :expires => 1.year.from_now } logger.warn "Saving cookie called '#{unique_key}'" else logger.warn "User attempted to submit another answer to the same poll." end render :nothing => true, :status => :ok end |