Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users
Re: Getting hashref instead of value
 

Index | Next | Previous | View Flat


fs5 at sanger

May 8, 2012, 9:03 AM


Views: 385
Permalink
Re: Getting hashref instead of value [In reply to]

Yes, definitely change that relationship name, evne if it's just for
your sanity: saying that something belongs to an account_id makes no
sense and makes the code unintuitive.
To be honest, I'd ditch the Schema::Loader generated stuff at some
point. It's great to get started with the project but I just found that
it's much more trouble than it's worth in the long run to try and keep
the files in a state that can be auto-updated by the Schema::Loader,
especialyl once you are at a point where the schema becomes more stable
anyway.

Frank



On 08/05/12 16:54, Kenneth S Mclane wrote:
> 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>
> To: The elegant MVC web framework <catalyst [at] lists>
> 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
> <mailto:ksmclane [at] us>> 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
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/


--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Subject User Time
Getting hashref instead of value ksmclane at us May 8, 2012, 8:13 AM
    Re: Getting hashref instead of value billcrawford1970 at gmail May 8, 2012, 8:24 AM
    Re: Getting hashref instead of value ari.constancio at gmail May 8, 2012, 8:25 AM
    Re: Getting hashref instead of value steve at matsch May 8, 2012, 8:25 AM
        Re: Getting hashref instead of value fs5 at sanger May 8, 2012, 8:31 AM
            Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:46 AM
    Re: Getting hashref instead of value rbwohlfarth at gmail May 8, 2012, 8:31 AM
    Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:33 AM
    Re: Getting hashref instead of value alexander.hartmaier at t-systems May 8, 2012, 8:33 AM
        Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:44 AM
    Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:37 AM
    Re: Getting hashref instead of value billcrawford1970 at gmail May 8, 2012, 8:48 AM
    Re: Getting hashref instead of value ksmclane at us May 8, 2012, 8:54 AM
    Re: Getting hashref instead of value billcrawford1970 at gmail May 8, 2012, 8:59 AM
    Re: Getting hashref instead of value fs5 at sanger May 8, 2012, 9:03 AM
    Re: Getting hashref instead of value alexander.hartmaier at t-systems May 8, 2012, 9:05 AM
        Re: Getting hashref instead of value ksmclane at us May 8, 2012, 9:15 AM
        Re: Getting hashref instead of value ksmclane at us May 8, 2012, 9:25 AM
    Re: Getting hashref instead of value alexander.hartmaier at t-systems May 8, 2012, 9:23 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.