3
4
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
|
# File 'app/controllers/wiser_timezone/wiser_timezone_controller.rb', line 3
def set_timezone
if params[:offset].present?
if params[:offset] == "skip"
cookies[:wiser_timezone_offset] = params[:offset]
elsif params[:offset] == "clear"
cookies[:wiser_timezone_offset] = nil
if current_user.present?
begin
current_user.update_attribute(:timezone, nil)
rescue; end
else
cookies[:wiser_timezone_offset] = params[:offset]
end
else
if current_user.present?
cookies[:wiser_timezone_offset] = nil
begin
current_user.update_attribute(:timezone, params[:offset])
rescue
raise "You probably need to run the migration. Please review the documentation."
end
else
cookies[:wiser_timezone_offset] = params[:offset]
end
end
end
redirect_to root_path
end
|