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
> 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