[Catalyst] $c->model('table') vs MyApp::Model::table

Matt S Trout dbix-class at trout.me.uk
Sat Jan 14 09:15:49 CET 2006


On Fri, Jan 13, 2006 at 11:43:11PM -0800, apv wrote:
> Just in case there is anyone left who hasn't filtered me to the 
> bit-bucket yet. (I'll have to start paying Matt consulting fees soon.)

Not that I'd object in the slightest ...

> With "use base qw( Catalyst::Model::CDBI::Sweet );" in the DB base 
> class, and having a subclass "MyApp::Model::tablename" this --
>     my @posts = MyApp::Model::tablename->retrieve_all();
> works perfectly while this --
>     my @posts = $c->model('tablename')->retrieve_all();
> gets "Caught exception "Can't call method "retrieve_all" on an 
> undefined value at..."
> 
> The first fully qualified package is fine but I like the "all from the 
> catalyst object" idiom better. Any tips or ideas for debugging it?

Have a look at the app startup output (loaded components). If that doesn't
help, Dumper the $c->components hashref and see what you've got.

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list