Proc.new do
visible do
bindings[:abstract_model].model.included_modules.exclude? ActiveRecord::Singleton
end
original_controller = controller
register_instance_option :controller do
abstract_model = bindings[:abstract_model]
model = abstract_model.model
if model.included_modules.include? ActiveRecord::Singleton
Proc.new do
if singleton = model.first
redirect_to show_path abstract_model.to_param, singleton.id
else
redirect_to new_path abstract_model.to_param
end
end
else
original_controller
end
end
end