# step one: # set up a base method to make sure your item exists, and # store your item information in $c->stash sub base : Chained('/') PathPart('item') CaptureArgs(1) { my ($self, $c, $itemid) = @_; my $item = $c->model('Item')->find($itemid); if ( $item == undef ) { $c->stash( error_msg => "This item does not exist" ); $c->detach("nonexistent"); } else { $c->stash( item => $item ); } }