Guest  

Show or hide header
Welcome Guest, posting in this forum require registration.




Derivante » Database » ActiveRecord » Could not find the association

Pages: [1]
Author Topic: Could not find the association
Killer_x
Member
Posts: 1
Post Could not find the association
on: December 6, 2009, 10:51

Hey, I have a small problem. My models are as follows:

class Ugroup extends ActiveRecord\Model
{
	static $table_name = 'user_groups';

	static $belongs_to = array(
			array('user'),
			array('group'),
		);
}

class User extends ActiveRecord\Model
{
	static $has_many = array(
		array('comments'),
		array('ugroups'),
		array('groups', 'through' => 'ugroups', 'foreign_key' => 'group_id'),
		);
}

class Group extends ActiveRecord\Model
{
	static $has_many = array(
			array('users', 'through' => 'ugroups'),
		);
}

Now when i try to this:

$u = User::find(1);
var_dump($u->ugroups);
var_dump($u->groups);

I get the following error:

Uncaught exception 'ActiveRecord\HasManyThroughAssociationException' with message 'Could not find the association ugroups in model User' in 

Any idea what I am doing wrong?

LP Killer_X

Pages: [1]
Page loaded in: 0.05 seconds.