[Catalyst] Mapping Schema to Model in Catalyst?

Brandon Black blblack at gmail.com
Mon May 15 17:07:21 CEST 2006


On 5/14/06, dennis <ddaupert at sbcglobal.net> wrote:
> John,
>
> You put quite a bit of time into your reply, and I want to thank you
> immensely. I'll be trying out your suggestions, tho with mother's day
> festivities, it might be a day or so. I've quickly plugged in the line:
>
> $c->stash->{quotes} = [$c->model('Quotes')->find($id)];
>
> but found that didn't work. The other bits will take a bit of study.
> But the really nice thing is, you provided a complete example, rather than
> just a fragment here and there:
>
> package myApp::Schema::db;
> package myApp::Schema::base;
> package myApp::Schema::db::members::members;
> package myApp::Model::db;
> controller access code example
>
> Plenty to think about, and learn from. I'll let you know how I get along.
>

In your original example, you seem to have blended together the
concepts of a Schema class and a Model class.  They are in fact very
distinct from each other.  Your "schema" class should "use base
DBIx::Class::Schema[::Loader];", and it should have nothing to do with
Catalyst or Models.

Your Model class on the other hand, should "use base
Catalyst::Model::DBIC::Schema", and have the config option
"schema_class" set to the classname of the Schema class above.

-- Brandon



More information about the Catalyst mailing list