Reputation: 2582
I would like to use a DBIx resultset helper, namely DBIx::Class::Helper::ResultSet::Random
, in my Catalyst application.
The package documentation shows how it is loaded from a DBIx::Class::ResultSet
class, but as far as I can tell, I have none of those because I'm using DBIx::Class::Schema::Loader
to create the schema.
I have tried putting this __PACKAGE__->load_components('Helper::ResultSet::Random')
in my Schema::Result
, but that didn't work: Can't locate object method "rand" via package "DBIx::Class::ResultSet".
How is this supposed to be done?
Upvotes: 0
Views: 184
Reputation: 93
You apply DBIC::Helper::ResultSet::Random
to your Result class (eg. you already have Schema/Result/Tbl.pm
which was created by DBIC::Schema::Loader
).
DBIC::Helper::ResultSet::Random
should be applied to ResultSet (not Result) class.
So, you just have to create Schema/ResultSet/Tbl.pm
like this:
package Schema::ResultSet::Tbl;
use strict;
use warnings;
use parent 'DBIx::Class::ResultSet';
__PACKAGE__->load_components('Helper::ResultSet::Random');
1;
Upvotes: 5