Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthorfrancois
    • CommentTimeFeb 21st 2008 edited
     

    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
    • CommentTimeFeb 21st 2008 edited
     

    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
    • CommentTimeFeb 22nd 2008
     

    I think this should be fixed->.

Add your comments
    Username Password
  • Format comments as