Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: Can't call method "find" on an undefined value

by Anonymous Monk
on Jan 12, 2012 at 20:28 UTC ( [id://947632]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Can't call method "find" on an undefined value
in thread Can't call method "find" on an undefined value

why is that? i don't get since $id has a value... my $id = $c->request->arguments->[0]*1; its like it's not seeing the value of $id

Replies are listed 'Best First'.
Re^6: Can't call method "find" on an undefined value
by tobyink (Canon) on Jan 12, 2012 at 21:54 UTC

    $id is irrelevant. As I say, it is the call to model that is failing, not the call to find. find is not being called because it can't be called if model returns undef.

      in what circumstances  c->model would return  undef. when the DB and schema exist? Schema
      package AddressBook::Schema::AddressDB::Result::Address; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE use strict; use warnings; use base 'DBIx::Class::Core'; __PACKAGE__->load_components("InflateColumn::DateTime"); =head1 NAME AddressBook::Schema::AddressDB::Result::Address =cut __PACKAGE__->table("addresses"); =head1 ACCESSORS =head2 id data_type: 'integer' is_nullable: 0 =head2 person data_type: 'integer' is_nullable: 0 =head2 location data_type: 'varchar' is_nullable: 1 size: 20 =head2 postal data_type: 'text' is_nullable: 1 =head2 phone data_type: 'varchar' is_nullable: 1 size: 20 =head2 email data_type: 'varchar' is_nullable: 1 size: 100 =cut __PACKAGE__->add_columns( "id", { data_type => "integer", is_nullable => 0 }, "person", { data_type => "integer", is_nullable => 0 }, "location", { data_type => "varchar", is_nullable => 1, size => 20 }, "postal", { data_type => "text", is_nullable => 1 }, "phone", { data_type => "varchar", is_nullable => 1, size => 20 }, "email", { data_type => "varchar", is_nullable => 1, size => 100 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to( person => 'AddressBook::Schema::AddressDB::Result::People'); # Created by DBIx::Class::Schema::Loader v0.07002 @ 2012-01-04 14:50:1 +5 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LXbQtPHwvP3E1JP8yppNhQ # You can replace this text with custom content, and it will be preser +ved on regeneration 1;

        No idea. On the few occasions I've used Catalyst, I never had much need for Catalyst::Model. But that's what the error message is saying.

        Can't call method "find" on an undefined value

        ... means that you're effectively trying to do this:

        undef->find($id)

        So the only thing that could be happening is that the model method is returning undef.

        If you don't believe me, run the following Perl one-liner at the command line...

        perl -e'undef->find(1)'

        And verify that you get the exact same error message.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://947632]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-03-19 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found