I'm confused about the "right" way to get a schema instance from within a
class method. If I've already got a resultset or resultsource instance, it's
easy. But from a class method within my model? Do I create a new connection
every time I need one, ie. MyApp::Schema->connect()?
To be specific:
package MyApp::Schema::Result::User;
use base 'DBIx::Class::Core';
...
sub create_user {
my ($class, $params) = @_;
# Want to call $user_rs->create() here after I've validated data.
# my $schema = MyApp::Schema->connect()?
}
My suspicion is that this should be an instance method, bc it represents the
table, not a user object. And the way to get an instance is to call
$rs->result_source on a result set. But when I call:
$c->model('DB::User')->result_source->create_user($params) it fails
with the msg:
Can't locate object method "create_user" via package
"DBIx::Class::ResultSource::Table"
--
Bikewise: http://www.bikewise.org
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/