Consider the following
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :maintenance_mode
private
def maintenance_mode
@settings = Setting.first
if @settings.maintenance
if logged_in?
if !current_user.admin?
redirect_to maintenance_url
end
else
redirect_to maintenance_url
end
end
end
is there a performance issue or bad practice in general to use before_actions globally? So i created a maintenance mode, where if in the database there is a true value on the maintenance attribute(which will be checked on each request i assume), and its likely not the best way, so is there a workaround in that?
I can imagine of a cron job/rake tast checking every minute in a background process but what i really want to know is before_action a bad thing in general?
Aucun commentaire:
Enregistrer un commentaire