Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    •  
      CommentAuthorfrancois
     

    Hello all,

    I have a problem with a HasOne relation between 2 objects User and Profile.

    here the specific code (layer models):

    class User extends ActiveRecord { var $hasOne = array('Profile' => array('dependent' => true)); }

    class Profile extends ActiveRecord {

    In the Code Documentation of the class AkHasOne (in Akelos framework) it's say that by declaring a condition 'dependent' when you destroy the object the object associated is destroyed too. In my case, It does'nt done.

    In AkHasOne when the afterDestroy function is called, the follow condition doesn't pass

                if(method_exists($object->$associated_id, 'destroy')){
                    $success = $object->$associated_id->destroy() ? $success : false;
                }
    

    Thanks in advance if someone could give me the solution.

    Francois

    •  
      CommentAuthorfrancois
     

    Hey,

    sorry but i just found the problem. It' me. I forgot to load the associated object in my destroy function in the controller.

    function destroy()
    {
        $this->user = $this->User->find($this->params['id'], array('include' => array('profile')));
        $this->user->destroy();
        $this->redirectTo(array('action' => 'listing'));
    }
    

    Francois

    • CommentAuthorKaste
     

    I think this should be fixed->.