1module FormTracking |
|
2 extend ActiveSupport::Concern |
|
4 private
|
|
|
6 def generate_form_token |
7 Authlogic::Random.friendly_token |
|
8 end |
|
|
10 def build_form_request |
11 { "form_token" => generate_form_token, "form_requested_at" => current_time } |
|
12 end |
|
|
14 def form_request_id |
15 petition_id.to_s
|
|
16 end |
|
|
18 def form_requests |
19 session["form_requests"] ||= {} |
|
20 session["form_requests"] |
|
21 end |
|
|
23 def form_request |
24 form_requests[form_request_id] ||= build_form_request
|
|
25 form_requests[form_request_id]
|
|
26 end |
|
|
28 def form_token |
29 form_request["form_token"] |
|
30 end |
|
|
32 def form_requested_at |
33 form_request["form_requested_at"] |
|
34 end |
|
|
36 def image_loaded_at |
37 cookies.encrypted[form_token]
|
|
38 end |
|
39end |