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

    Hi friends

    How can I implement one-one relationship in akelos?

    assume I have these two classes: 1.Topic 2.User

    each class has one-one association to the other one.

    regards

    • CommentAuthorKaste
     

    depending on what you did with Akelos or rails so far this might help:

    a one-to-one relationship is in terms of Akelos a has_one with a corresponding belongs_to relation.

    the model which belongs_to something always holds the column/attribute with the foreign key.

    so, f.i.

    class Topic extends ActiveRecord
    {
        var $belong_to = array('user');
    }
    
    class User extends ActiveRecord
    {
         var has_one = array('topic');
    }
    

    wihout overriding some options Akelos now expects a column named user_id in the table topics.