[Catalyst] Using relations in catalyst

Zbigniew Lukasiak zzbbyy at gmail.com
Tue Aug 23 07:58:24 CEST 2005


First perhaps you have the item in your templates as 'item' not
'pr_ping_def'?  So you should have 'item.server.name' in the template.

You can also try the 'Stringify' feature of CDBI:

__PACKAGE__->columns(Stringify => qw/name/);

Read about it in perldoc Class::DBI. 

Then you can try to extract the problem from the whole application -
write a short script using the model.  Something like:

use Jabbernet::M::CDBI::PrPingDef;

my $x = Jabbernet::M::CDBI::PrPingDef->retrieve(1);
print $x->server . "\n";
print $x->server->name . "\n";

-- Zbyszek

On 8/22/05, Wijnand Wiersma <wijnand at nedbsd.nl> wrote:
> I think (no, I am sure) I don't get it yet.
> I have to Tables: pr_ping_def and server. I have setup both with a
> scaffolding controller.
> I changed M/CDBI.pm to use Catalyst::Model::CDBI::Sweet
> and in the M/CDBI/PrPingDef.pm I have:
> __PACKAGE__->has_a( server => 'Jabbernet::M::CDBI::Server' );
> 
> I updated the default template (that get's generated when you want a
> scaffolding table) so it only displays the server and ipaddress columns.
> The server is displayed as a id.
> I want the column name of the server table to be displayed instead.
> 
> I tried a lot of things, at the irc channel the suggestion was to use
> pr_ping_def.server.name, but now it doesn't output anything.
> 
> Could it be a problem that the pr_ping_def table has multiple keys?
> If so, is it possible to fix this? I cannot alter the database design.
> 
> Wijnand
> 
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>



More information about the Catalyst mailing list