[Dbix-class] using HasMany with object references

Matt S Trout dbix-class at trout.me.uk
Tue Dec 6 01:06:14 CET 2005


On Mon, Dec 05, 2005 at 05:28:19PM -0600, Justin Guenther wrote:
> On 12/2/05, Matt S Trout <dbix-class at trout.me.uk> wrote:
> 
> > Assuming the other side has a belongs_to set up, just calling
> >
> > $foo_obj->belongs_to_rel($obj_which_has_many_foo);
> >
> > should do the trick.
> 
> 
> The class does have belongs_to set up, but there doesn't seem to be a method
> called belongs_to_rel

Maybe I should have said $belongs_to_rel to clarify the metasyntactic variable

> Here's my setup code:
> 
> In the class Treatment: (which has_many Phases)
> ...
> __PACKAGE__->has_many('phases' => 'SaskSAGE::Model::DBIC::Phase',
>                       'treatment_id');
> ...
> 
> In the class Phase: (which belongs_to Treatment)
> 
> ...
> __PACKAGE__->belongs_to('treatment_id' =>
> 'SaskSAGE::Model::DBIC::Treatment');
> ...
> 
> I'm trying to add a phase to a treatment by calling
> 
> $phase->belongs_to_rel($treatment);
> 
> but this method does not exist.

$phase->treatment_id($treatment);

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list