not yet

Jared Carroll

Ok here’s an app as of right now.

All the app consists of are some forms for creating users, some forms for users to create comments, plus 1 additional page that displays each user and the total number of comments they have created. There is NO page that displays a comment and its user who created it.

The correct domain model based on the requirements right now is:

class User < ActiveRecord::Base

  has_many :comments


class Comment < ActiveRecord::Base

This association is unidirectional, it can only be traversed in one direction. There is no point in making this association bidirectional by adding a corresponding belongs_to :user in Comment. Adding that would be premature and a case of massive over-engineering. Since the association from Comment to User currently is not used in the app, adding it would just cause unnecessary complexity.

There is nothing wrong with unidirectional associations. Don’t make all associations bidirectional when its just not necessary; someday it might be but until then don’t do it.