[Catalyst] has_many and belongs_to with InstantCRUD

Zbigniew Lukasiak zzbbyy at gmail.com
Wed Jun 14 16:03:19 CEST 2006


Hi,

In the current InstantCRUD there is no support for any relations
between tables.  You need to to extend it yourself for that
functionality.

The 'instantcrud' prefix for the DBIx::Class classes is not needed - I
did not add anything to the DBIx::Class library - all standard
DBIx::Class documentation applies here and the relations should take
the names of the classes:
__PACKAGE__->belongs_to(user => 'DBSchema::Users');
is correct since the other class is 'DBSchema::Users'

Regards,
Zbyszek

On 6/14/06, Kevin Old <kevinold at gmail.com> wrote:
> Hello everyone,
>
> I'm trying to get InstantCRUD to work with 2 tables and can't seem to
> figure out what "path" I'm suppose to provide to the table modules.
>
> Here's what I have, any help is appreciated:
>
>
> package DBSchema::Messages;
>
> use strict;
> use warnings;
> use base 'DBIx::Class';
>
> __PACKAGE__->load_components(qw/PK::Auto::Pg Core/);
> __PACKAGE__->table('messages');
> __PACKAGE__->add_columns(qw/id msg c_time email_to email_from/);
> __PACKAGE__->set_primary_key('id');
> __PACKAGE__->belongs_to(user => 'instantcrud::DBSchema::Users');
>
> package DBSchema::Users;
>
> use strict;
> use warnings;
> use base 'DBIx::Class';
>
> __PACKAGE__->load_components(qw/PK::Auto::Pg Core/);
> __PACKAGE__->table('users');
> __PACKAGE__->add_columns(qw/id username password/);
> __PACKAGE__->set_primary_key('id');
> __PACKAGE__->has_many(messages => 'instantcrud::DBSchema::Messages');
>
> Couldn't instantiate component "instantcrud::Model::DBICSchemamodel",
> "Cannot load schema class 'DBSchema':
> DBIx::Class::Relationship::BelongsTo::belongs_to(): Can't infer join
> condition for user on DBSchema::Messages; unable to load
> instantcrud::DBSchema::Users at
> /home/kevin/projects/instantcrud/script/../lib/DBSchema/Messages.pm
> line 12
>
> I've tried this path as well in their respective modules above:
> __PACKAGE__->has_many(messages => 'DBSchema::Messages');
> __PACKAGE__->belongs_to(user => 'DBSchema::Users');
>
> Any help is appreciated,
> Kevin
> --
> Kevin Old
> kevinold at gmail.com
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>


-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/



More information about the Catalyst mailing list