acts_as_list problem

0 views
Skip to first unread message

tom

unread,
Oct 26, 2007, 7:51:25 AM10/26/07
to Akelos PHP Framework
Hi,

I've got troubles inserting new list items using the methods of the
acts_as_list observer.

My models look like this:

class Customer extends ActiveRecord
{
var $has_many = array( 'people' => array('order' => 'list_position',
'dependent' => 'destroy'));
...

}

class Person extends ActiveRecord
{
var $belongs_to = 'customer';
var $acts_as = array('list' => array('scope' => 'customer_id',
'column' => 'list_position'));
...
}

So, a customer object has a list of Persons.

Now, when I create a new Person and insert it into a Customer's Person
list, shouldn't I be able to do it like:

$this->my_person->list->insertAtPosition( 1 ); ??

Whenever I tried this, Akelos created a new empty Person in my
database table. The list_position field was set to 1 though on that
otherwise blank row.

Any ideas?

Regards,

TS

Kaste

unread,
Oct 26, 2007, 4:24:14 PM10/26/07
to akelos-f...@googlegroups.com
Hi,

> So, a customer object has a list of Persons.
>
> Now, when I create a new Person and insert it into a Customer's Person
> list, shouldn't I be able to do it like:
>
> $this->my_person->list->insertAtPosition( 1 ); ??

again quick & dirty:

$Ellen =& new Person(...);
$Ellen->list->insertAtPosition(1); //Ellen is now in your database

$Customer->person->add($Ellen);


again, short but hope it helps.

and welcome :-)
Kaste


Reply all
Reply to author
Forward
0 new messages