[Catalyst-dev] Problems with $c->model() and _comp_singular()

Matt S Trout dbix-class at trout.me.uk
Tue Aug 8 12:53:09 CEST 2006


Nathan Kurz wrote:
> I was just changing some things with my DBIx::Class schema's, and ran
> into some problems that stumped me for a bit.  I had been calling
> $c->model() and having it choose the correct model, but after I
> rearranged the items in MyApp::Model::* things stopped working.  
> 
> I put in a debug statement like this:
>   sub test : Local {
>       my ($self, $c) = @_;
>       $c->log->dumper('ref $c->model: ' . ref $c->model);
>   }
> And to my surprise found that $c->model made no sense at all:
>   [debug] $VAR1 = 'ref $c->model: DBIx::Class::ResultSet';

That makes perfect sense - it'll be finding the first MyApp::Model::* in hash 
key order; if that happens to be a DBIC::Schema sub-model (i.e. 
Model::DBIC::Foo) you'll get back a resultset as $c->model("DBIC::Foo") would 
return.



More information about the Catalyst-dev mailing list