Catalyst Improving your Catalyst Application #45

Combine with configuration

package MyApp::BaseController::CRUD;
use base 'Catalyst::Controller';

sub show_all :Local {
    my ($self, $c) = @_;
    my $model_name = $self->{model_name} || die 'Need model name';
    $c->stash->{records} = [ $c->model("DBIC::$model_name")->all ];
}

package MyApp::Controller::Users;
use base 'MyApp::BaseController::CRUD';

__PACKAGE__->config( model_name => 'User' );
Infinity Interactive