holli has asked for the wisdom of the Perl Monks concerning the following question:

Brethren,I am about to lose my hair about this. I am trying to subclass a DBIx Resultset-object. You might think thats easy because its FAQ , and I did follow the instructions there, but I keep getting this bloody error, no matter what I try:
Couldn't instantiate component "Infocenter::Model::InfoDB", "Cannot load schema class 'Infocenter::Schema::InfoDB': DBIx::Class::Schema::throw_exception(): Can't locate object method "resultset_class" via package "Infocenter:: +Schema::InfoDB::AuSchuldner" at ...
This is the code:
package Infocenter::Schema::InfoDB::AuSchuldner; use strict; use warnings; #use base 'Infocenter::Schema::InfoDB::Result'; use base 'DBIx::Class'; __PACKAGE__->resultset_class('Infocenter::Schema::InfoDB::ResultSet::A +uSchuldner'); __PACKAGE__->load_components("Core"); __PACKAGE__->table("au_schuldner"); __PACKAGE__->add_columns( "id", { data_type => "integer", is_nullable => 0, size => 4, }, .... package Infocenter::Schema::InfoDB::ResultSet::AuSchuldner; use strict; use warnings; use lib qw(./lib ../lib); use base 'DBIx::Class::ResultSet'; 1;
As it seems the inheritance is not working, but I dont know why. I am sure its something simple, plez send the codez


holli, /regexed monk/

Replies are listed 'Best First'.
Re: trouble subclassing DBIx::Class Resultsets (when using Catalyst?)
by Anonymous Monk on Mar 30, 2008 at 13:25 UTC
Re: trouble subclassing DBIx::Class Resultsets (when using Catalyst?)
by shmem (Chancellor) on Mar 30, 2008 at 19:31 UTC
    Hmm.. risking a shot in the dark, since I haven't used DBIx::Class - but does re-ordering that file make any difference?
    package Infocenter::Schema::InfoDB::ResultSet::AuSchuldner; use strict; use warnings; use lib qw(./lib ../lib); use base 'DBIx::Class::ResultSet'; package Infocenter::Schema::InfoDB::AuSchuldner; use strict; use warnings; #use base 'Infocenter::Schema::InfoDB::Result'; use base 'DBIx::Class'; __PACKAGE__->resultset_class('Infocenter::Schema::InfoDB::ResultSet::A +uSchuldner'); ... 1;

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: trouble subclassing DBIx::Class Resultsets (when using Catalyst?)
by Anonymous Monk on Mar 30, 2008 at 13:20 UTC
    You have use base 'DBIx::Class::ResultSet'; in the wrong package?
Re: trouble subclassing DBIx::Class Resultsets (when using Catalyst?)
by holli (Abbot) on Apr 04, 2008 at 19:50 UTC
    With the help from some kind people at #dbix-class I was able to work my error out, I share it for the next poor soul who runs into this.

    My error was simply not groking, that when used with Catalyst, the resultset class needs to be located in lib/MyApp/Resultset/Table.pm. Duh! So simple.


    holli, /regexed monk/
      The location should be lib/MyApp/ResultSet/Table.pm (notice the capital S in ResultSet) to be consistent with your class name above.