[Dbix-class] Catalyst::Model::DBIC::Schema

Andrew Main andrew.main at gmail.com
Mon Mar 6 01:04:17 CET 2006


I think that you're using the wrong name for your model; instead of
the name of the schema class, you need the name of your catalyst
model.  You should be basically following the same practice you do in
Catalyst in general:
http://search.cpan.org/~mramberg/Catalyst-5.65/lib/Catalyst.pm#%24c-%3Emodel(%24name)

So instead of:
my $rs = $c->model('DB_Schema::History')->find('BHP','2006-02-03');

You should try:
my $rs = $c->model('MyMod::History')->find('BHP','2006-02-03');

Also, this is another example of how "Foo" examples in documentation
can lead to confusion, although the documentation is totally correct. 
Further, I'm a little confused about what good names would be for the
Catalyst model class and for the schema class.

In my own code I don't need a separate "connect"  call, and I have it
set up pretty similarly to you.

In any case, I'm very new to DBIx::Class, so I may be totally off base
here, but its worth a shot...

-Andrew


On 3/5/06, Maurice Height <mauriceh at bigpond.net.au> wrote:
> I get an error when trying to access data with DBIC in Catalyst.
> I am sure I am doing something dumb like not doing a "connect" first
> but I can't figure out how that is done from the
> Catalyst::Model::DBIC::Schema docs.
>
> I have a Model class, built with Catalyst::Helper::Model::DBIC::Schema
>
> package MyApp::Model::MyMod;
> use strict;
> use lib 'C:/MyCode/DB_Apps/ShareMan/Code';
> use DB_Schema;
> use base 'Catalyst::Model::DBIC::Schema';
> __PACKAGE__->config(
>     schema_class => 'DB_Schema',
>     connect_info => [ 'DBI:mysql:database=shareman',
>                       'root',
>                       '....',
>                       {},
>                     ],
> );
>
> Then in controller MyApp I have:
>
> sub some_data : Global {
>     my ($self, $c) = @_;
>     my $rs = $c->model('DB_Schema::History')->find('BHP','2006-02-03'); # 94
>     .....
> }
>
> I get the error:
> Caught exception in MyApp->some_data "Can't call method "find" on an
> undefined value at C:/TEST/MyApp/script/../lib/MyApp.pm line 94."
>
> Thanks
> Maurice
>
>
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
>



More information about the Dbix-class mailing list