Sha256: ebfc345d7b934f29c609ac91e179207750b47a629c43403a89d7c55259091fcf
Contents?: true
Size: 1.17 KB
Versions: 45
Compression:
Stored size: 1.17 KB
Contents
module Tenon class BaseController < ApplicationController layout :layout_for_resource before_filter :set_title before_filter :require_admin, unless: :devise_controller? rescue_from CanCan::AccessDenied do |exception| flash[:warning] = 'You are not authorized to access that page.' redirect_to root_path end private def layout_for_resource if devise_controller? 'tenon/login' else 'tenon/application' end end def set_title case params[:action] when 'new', 'create' @page_title = "New #{params[:controller].gsub('tenon/', '').singularize.humanize}".titleize when 'edit', 'update' @page_title = "Edit #{params[:controller].gsub('tenon/', '').singularize.humanize}".titleize else @page_title = params[:controller].gsub('tenon/', '').humanize.titleize end @page_title = 'Tenon' if params[:controller].gsub('tenon/', '') == 'index' end def require_admin unless current_user && current_user.staff? flash[:warning] = "You're not authorized for that." if current_user redirect_to new_user_session_path end end end end
Version data entries
45 entries across 45 versions & 1 rubygems