Skip to content

Instantly share code, notes, and snippets.

@somaria
Created February 19, 2022 08:31
Show Gist options
  • Save somaria/016733a02b7781deb1d720cf1e288a70 to your computer and use it in GitHub Desktop.
Save somaria/016733a02b7781deb1d720cf1e288a70 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
def prevent_page_cache
@turbolinks_no_cache = true
response.headers['Cache-Control'] = 'no-cache, no-store'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
end
def render_not_found
raise ActionController::RoutingError.new('Not Found')
end
def require_staff_login
login = session[:login]
puts "require staff login"
puts session[:login]
if login.nil?
logger.debug 'user is not logged in'
redirect_to auth_staff_path
return
end
if login['type'] != 'staff'
logger.debug 'user is not staff'
redirect_to auth_staff_path
return
end
@staff = Staff.find(login['staff_id'])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment