Maybe this might work for you:
class BaseController < ActionController::Base
def BaseController.model(model_name) @model_class = const_get(Inflector.classify(model_name)) @model_var = model_name end
def show inst_var="@#{model_var}", model_class.find(params[:id] instance_variable_set(inst_var) if inst_var.active? render :action => 'show_active_true' else render :action => 'show_active_false' end rescue ActiveRecord::RecordNotFound logger.error("An attempt has been made to access a #{model_class.name} that does not exist in the database. The #{model_class.name} id was #{params[:id]}") flash_failure 'An attempt has been made to access a #{model_class.name} that does not exist in the database.' redirect_to :action => 'index' end
end
And:
class HomeController < BaseController model :home end
Cheers, Max