I want to configure something so that if the account in my application is disabled, I want all requests to be redirected to the message "disabled".
I installed this in my ApplicationController application:
class ApplicationController < ActionController::Base
before_filter :check_account
def check_account
redirect_to :controller => "main", :action => "disabled" and return if !$account.active?
end
end
Of course, this does not work, because it goes into an endless loop if the Account is inactive. I was hoping to use something like:
redirect_to :controller => "main", :action => "disabled" and return if !$account.active? && @controller.controller_name != "main" && @controller.action_name != "disabled"
but I noticed that in Rails v2.1 (what I use), @controller is now a controller, and this does not seem to work in ApplicationController.
What would be the best way to implement something like this?
source
share