I am trying to use DBIx:Class. I have successfully created the Schema class using DBIx:class::Schema::Loader.
I can also connect to the database.
#!/usr/bin/perl -w
use Test::More tests => 5;
use_ok('Models::ModelRole');
use_ok('Models::User');
my $model = Models::User->new();
cmp_ok($model->{ModelName}, 'eq', 'User', 'model name');
ok($model->connect(), "connect"); #works
ok($model->{schema}->resultset('User'));
The last test returns the error message:
DBIx::Class::Schema::source(): Can't find source for User at ./tests/ModelsTests.pl line 29
This is the structure of the generated class from DBIx:Class::Schema::Loader:
This is the model user class:
package Models::User;
use DB::Glued::Schema::Result::User;
use Models::ModelRole;
use Moose;
with 'Models::ModelRole';
sub BUILD {
my $self = shift;
$self->{schema} = Glued::Schema::Result::User->new();
my @name = split('::', __PACKAGE__);
$self->{ModelName} = $name[-1];
}
1;
I hope this is enough information.