[Catalyst] Catalyst and Moose with "has" many_to_many

will trillich will.trillich at serensoft.com
Thu Nov 25 03:43:02 GMT 2010


Greetings Catalystery: Got a new question, trying to implement a
many_to_many
relationship via Moose... The DBIC portion of the puzzle is straightforward,
we've got
that working just fine.

Here's part I understand -- we have a controller that's referring to a form:

has 'form' =3D> (
    isa     =3D> 'MyApp::Controller::Incident::IncidentForm',
    is      =3D> 'rw',
    lazy    =3D> 1,
    default =3D> sub { MyApp::Controller::Incident::IncidentForm->new },
)

then

$c->stash->{form} =3D $self->form; # etc

Piece of cake!



But how would you represent and then refer to a *many_to_many* relationship
such as

has 'actor_role' =3D> (
    isa     =3D> 'MyApp::Controller::DB::Result::ActorRole',
    is      =3D> 'rw',
    lazy    =3D> 1,
#  default =3D> sub { MyApp::Controller::DB::Result::ActorRole->new }, # no=
t!
#  default =3D> sub { ...->add_to_roles(??) }
)

And then once we get the "has" straightened out, how do we use it?

%roles =3D $self->actor_role( @get_roles ); # ??
@success =3D $self->actor_role( %set_new_roles ); # ??

I've looked through
http://search.cpan.org/~frew/DBIx-Class-0.08124/lib/DBIx/Class/Relationship=
.pm#many_to_many
until my eyes cross on their own :(



Or am I barking up the wrong tree?

-- =

Failure is not important. How you overcome it, is.
-- Nick Vujicic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101124/3b042=
4e8/attachment.htm


More information about the Catalyst mailing list