[Catalyst] Controller::DBIC::API::REST

Jon jonfdaily at wetxt.com
Wed Jan 20 14:12:25 GMT 2010


Hello,

I am using Controller::DBIC::API::REST for form processing, and
general insert/update/deletes in my application.  This is my first
time using it though, and I'm having a bit of trouble with it.  I
would like to be able to set up default parameters, and add additional
values in the Controller class when the create, or update methods are
called.  Can anyone give me some help to achieve this?

My code looks something like this,

use base qw/Catalyst::Controller::DBIC::API::REST/;

__PACKAGE__->config
    ( action => { setup => { PathPart => 'user', Chained =>
'/api/rest/rest_base' } },
      class => 'App::Users',
      create_requires => ['name_first','name_last','email','password'],
      );

sub create :Chained('setup') :Args(0) :PathPart('create') {
    my ($self, $c) = @_;

    $res = $self->next::method($c);

    if ( $c->stash->{created_object} ) {
        $c->forward('/user/just_registered');
    }
    else {
         # Handle error scenario
    }
}

I would like to be able to add a 'status' parameter (among others) to
the create method prior to inserting the row.  Any suggestions on how
to achieve this?

Thanks,

- Jon



More information about the Catalyst mailing list