/
application_controller.rb
38 lines (30 loc) · 1.1 KB
/
application_controller.rb
1
2
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
31
32
33
34
35
36
37
38
class ApplicationController < ActionController::Base
include GDS::SSO::ControllerMethods
before_filter :require_signin_permission!
before_filter :set_cache_buster
protect_from_forgery
rescue_from ActionController::InvalidAuthenticityToken do
render text: "Invalid authenticity token", status: 403
end
def user_for_paper_trail
current_user.name if user_signed_in?
end
def info_for_paper_trail
{ user_id: current_user.id } if user_signed_in?
end
def render_error(status, options={})
@custom_header = options[:header]
@custom_body = options[:body]
render "errors/error_#{status}", status: status, layout: 'error_page'
end
# http://stackoverflow.com/questions/711418/how-to-prevent-browser-page-caching-in-rails
def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
private
def verify_authenticity_token
raise ActionController::InvalidAuthenticityToken unless verified_request?
end
end