[Catalyst] Getting hashref instead of value

Kenneth S Mclane ksmclane at us.ibm.com
Tue May 8 15:54:45 GMT 2012


Here are the two relationships predefined in the account.pm file:

__PACKAGE__->belongs_to(
  "account_id",
  "dbms::Schema::Result::Account",
  { account_id => "account_id" },
);

=head2 accounts

Type: has_many

Related object: L<dbms::Schema::Result::Account>

=cut

__PACKAGE__->has_many(
  "accounts",
  "dbms::Schema::Result::Account",
  { "foreign.account_id" => "self.account_id" },
  {},
);
 
So you're saying I should do this:

__PACKAGE__->belongs_to(
  "account",
  "dbms::Schema::Result::Account",
  { account_id => "account_id" },
);

?



From:
Will Crawford <billcrawford1970 at gmail.com>
To:
The elegant MVC web framework <catalyst at lists.scsys.co.uk>
Date:
05/08/2012 10:49 AM
Subject:
Re: [Catalyst] Getting hashref instead of value





On 8 May 2012 16:44, Kenneth S Mclane <ksmclane at us.ibm.com> wrote:
The Catalyst helper script created most of the relationships. I added a 
few at the bottom of the Account.pm file to since there are a bunch of 
them based on "account_id", so I made them myself and gave them different 
names. progress, metrics, compliance are ones I did. the one called 
"department_id" was created by the helper and I didn"t want to chang it. I 
guess I could redefine it below with a different name. Strangely, the 
account table has a belongs to AND a has many to itself based on the 
account_id field. I am actually looking to get a list nad that is what I 
get except for the one field. 

Basically you just need to rename the relationship to call the accessor 
"account" instead of "account_id", so that .account_id refers to the raw 
ID column, not the object._______________________________________________
List: Catalyst at lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: 
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20120508/085b8f19/attachment.htm


More information about the Catalyst mailing list