[Catalyst] How can it be - wrong model returned?

Ash Berlin ash_cpan at firemirror.com
Thu Mar 6 11:26:01 GMT 2008


On 6 Mar 2008, at 11:12, Alex Povolotsky wrote:

> Hello!
>
> I've made a simple many-to-many relationship for user/roles  
> authentication, and suddenly found that
>
>   my $model = $c->model('Pwuser')->search()->all();
>   my $roles = $c->model('Role')->search()->all();
>   my $ur = $c->model('UserRole')->search()->all();
>
> results in
>
> SELECT me.uid, me.login, me.password FROM pwuser me:
> SELECT me.uid, me.rid FROM user_role me:
> SELECT me.uid, me.rid FROM user_role me:
>
> nothing get selected from role table, and $c->model('Role')->search- 
> >all selects from wrong table.
>
> How can it be and what can I do?...
>
> Alex.

You are passing the wrong thing to $c->model and its falling back to  
the (hateful) regexp search.

Assuming your DBIC::Schema model is MyApp::Model::DBModel you want $c- 
 >model('DBModel::Role').

-ash



More information about the Catalyst mailing list