[Catalyst] CatalystX::CRUD Storage Error

Peter Karman peter at peknet.com
Fri Jul 17 04:33:38 GMT 2009


Amiri Barksdale wrote on 7/16/09 10:48 PM:
> On Thu, Jul 16, 2009 at 09:36:47PM -0500, Peter Karman wrote:
> | what does your Controller config look like? Specifically, what is the value of
> | 'model_name' and what does the model_name class look like? The model_name value
> | should be the same for all your Controllers (the main subclass of
> | Catalyst::Model::DBIC::Schema in your Model directory).
> 
> Progress!
> 
> I changed all my CRUD controllers to look like this:
> 
>    package ml2::Controller::UI::CRUD::Band;
> 
>    use strict;
>    use warnings;
> 
>    use base qw/CatalystX::CRUD::Controller/;
> 
>    __PACKAGE__->config(
>        'model_adapter' => 'ml2::ModelAdapter::UI::CRUD::Adapter',
>        'model_name' => 'DB', ### Did not work with 'ml2::Model::DB'
>    );
> 
>    1;
> 
> And now I get an error:
> 
>    Couldn't instantiate component "ml2::Controller::UI::CRUD::Band", "Can't
>    use an undefined value as a HASH reference at
>    /home/amiri/mlrepo/lib/perl5/CatalystX/CRUD/ModelAdapter/DBIC.pm line
>    179."Compilation failed in require at ./script/ml2_server.pl line 66.
> 
> So, I am thinking my adapter may be misconfigured. 

No your adapter is fine.

Your controller needs more info. Try (at a minimum):

 __PACKAGE__->config(
        'model_adapter' => 'ml2::ModelAdapter::UI::CRUD::Adapter',
        'model_name'    => 'DB',
        'model_meta'    => {
           dbic_schema    => 'Band', # assuming this is the moniker name
           resultset_opts => {}
        },
 );

Look at the example MyApp in the t/ directory of the cpan dist for more examples.

Also, your controller inherits from the base CatalystX::CRUD::Controller, which
doesn't really *do* anything by default. I.e., you need a form handler to
serialize and validate your model. Look at CatalystX::CRUD::Controller::RHTMLO
for one example. Or consider writing a controller base class that adapts your
favorite form handler (HTML::FormFu or Form::Processor or ...).



-- 
Peter Karman  .  http://peknet.com/  .  peter at peknet.com
gpg key: 37D2 DAA6 3A13 D415 4295  3A69 448F E556 374A 34D9



More information about the Catalyst mailing list