[Catalyst] Database schema -- Can't locate object method "new" via package

Sarah Berry berry.sarah at gmail.com
Mon Jun 26 20:08:01 CEST 2006


If anyone's interested, here is the solution to my problem, for the
sake of any future newbs searching the mailing list archives. Thank
you all for your help.

First of all, I didn't have DBIx::Class::Schema::Loader installed. I
had incorrectly assumed it was just a subset of DBIx::Class, which I
did already have installed.

Here's the code that worked for me.
Contents of Model/SensorLogDB.pm:

package vieDB::Model::SensorLogDB;

use warnings;
use strict;

use base 'Catalyst::Model::DBIC::Schema';

__PACKAGE__->config(
        schema_class => 'vieDB::Schema::SensorLogDB',
);

return 1;


Contents of Schema/SensorLogDB.pm:

package vieDB::Schema::SensorLogDB;

use warnings;
use strict;

use base qw/DBIx::Class::Schema::Loader/;

__PACKAGE__->loader_options( relationships => 1 );

__PACKAGE__->connection( 'xxx', 'xxx', 'xxx', { AutoCommit => 1 } );

my $dsn = 'xxx';
my $user = 'xxx';
my $password = 'xxx';
my $options = {AutoCommit => 1};

1;


Also in the Schema folder is an empty folder called SensorLogDB.

I had to take any DBIx::Class stuff out of the main vieDB.pm.

And now I can access my database through methods in the Controller.



More information about the Catalyst mailing list