I have been building catalyst apps of a number of years now. This is the first time I am getting an error trying to open a view. When I call the view (there is only one view), I get the following error:
Can't call method "model" on an undefined value at....
The following snippet of code is used in Root.pm,. This is what is generating the error on the browser. Again, this is not the first time I am using this catalyst method to call a model.
my $model = $c->model( 'mypackage' );
my $result = $model->get_my_results();
The alternative is to use:
use mypackage;
my $model = 'mypackage';
my $results = $model->get_my_results();
Has any one ever encounter this before? If yes, can you tell me how you resolved it.
Thanks
EDITED
Please note, as indicated in the original post, this is a Perl Catalyst app. The $c is a Catalyst object. In the Root.pm file, $c is received as follows:
sub myform :Local {
my ($self, $c) = @_;
my $model = $c->model( 'mypackage' );
my $results = $model->get_my_results();
.
.
.
}
Typo? Did you mean
$c->modelin your first line?