5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/poll_response_controller.rb', line 5
def create
@page = Page.find(params[:page_id])
@page.request, @page.response = request, response
poll = Poll.find(params[:poll_id])
current_poll = Poll.find_current
@page.submitted_polls = @page.poll_cookies(cookies)
if !@page.submitted_polls.include?(poll.id) && (!current_poll || current_poll.id == poll.id)
begin
poll_cookie_duration = eval(config['polls.cookie_duration']).from_now || 1.month.from_now
rescue Exception => exc
poll_cookie_duration = 1.month.from_now
end
cookies["poll_#{poll.id.to_s}"] = { :value => "#{@page.id}", :expires => poll_cookie_duration }
@page.submitted_polls << poll.id
poll_response = Option.find(params[:response_id])
poll.submit_response(poll_response)
end
redirect_to @page.url
end
|