[Catalyst] Update join was working, now getting Can't locate object method error

Dennis Daupert ddaupert at sbcglobal.net
Sat Jul 15 20:05:12 CEST 2006


Grrrrrrrr. I had this working, but changed code to use integer values that reference another table, now getting error msg:

"Can't locate object method "add_to_user_quotes" via package "Catapult::Model::CatapultDB::Quotes" "../lib/Catapult/Controller/Text/Quote.pm line 233."

I'm using HTML::Widget. Initial INSERT into quotes table succeeds, but the 
update to the join table fails. I don't understand why I'm getting this error, been thru the code over and over. I must be doing something silly, just don't know what yet. Did I mention I'm not a DBA? ;-)

Details:

#-------------------------------------------------
package Catapult::Controller::Text::Quote;
<snip>
my $quote = $c->model('CatapultDB::Quotes')->new({});
$quote->populate_from_widget($result); # that works
if ( $c->user_exists ) {                            # user does exist
  my $user_id = $c->user->obj->id;        # id is as expected
  $quote->add_to_user_quotes({user_id => $user_id}); #<<line 233
}
#-------------------------------------------------
package Catapult::Schema::CatapultDB::Quotes;
<snip>
__PACKAGE__->table('quotes');
__PACKAGE__->add_columns(qw/id quote author category active /);
__PACKAGE__->set_primary_key(qw/id/);
# relationships:
__PACKAGE__->has_many(map_user_quotes => 'Catapult::Schema::CatapultDB::UserQuotes', 'quote_id');

#-------------------------------------------------
package Catapult::Schema::CatapultDB::UserQuotes;
<snip>
__PACKAGE__->table('user_quotes');
__PACKAGE__->add_columns(qw/user_id quote_id/);
__PACKAGE__->set_primary_key(qw/user_id quote_id/);
# relationships:
__PACKAGE__->belongs_to(user => 'Catapult::Schema::CatapultDB::Users', 'user_id');
__PACKAGE__->belongs_to(quote => 'Catapult::Schema::CatapultDB::Quotes', 'quote_id');

#-------------------------------------------------
package Catapult::Schema::CatapultDB::Users;
<snip>
__PACKAGE__->table('users');
__PACKAGE__->add_columns(qw/id fname lname email username password active /);
__PACKAGE__->set_primary_key(qw/id/);
# relationships:
__PACKAGE__->has_many(map_user_role => 'Catapult::Schema::CatapultDB::UserRoles', 'user_id');
__PACKAGE__->has_many(map_user_quotes => 'Catapult::Schema::CatapultDB::UserQuotes', 'user_id');
#-------------------------------------------------

best,

/dennis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060715/f6898695/attachment.htm 


More information about the Catalyst mailing list