in reply to I need help adding a new model to a legacy Catalyst setup
This gives you the bare ResultSet object without wrapping it with a Catalyst model object, which sometimes makes error messages clearer.my $db= $c->model('DB'); my $rs= $db->resultset('OtherThing');
For frequently used DBIC resultsets, it can be nice to add a convenience method to the application object (in Console.pm) like this:
Then you can callsub otherthing { my $self= shift; my $rs= $self->model('DB')->resultset('OtherThing'); return @_? $rs->find(shift) : $rs }
$c->otherthing($id); # fetch an OtherThing row by primary key $c->otherthing->search_rs(...)->all # convenient access to resultset
There is no need to use the create scripts. I never do because it takes longer to remember the syntax for the create script and add my module boilerplate to the top of the file than to just "Save As" from the other file most like the one I want to create.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: I need help adding a new model to a legacy Catalyst setup
by LittleJack (Beadle) on Mar 20, 2022 at 20:11 UTC |