Do ActiveRecord relations defy DRY ?

Why do we need to specify both sides of a relationship? eg. class Category < ActiveRecord::Base   has_many :recipes end

class Recipe < ActiveRecord::Base   belongs_to :category end

Doesn't "has_many :recipes" in Category imply "belongs_to :category" in Recipe?

I am sure there is a good explanation, but at the moment it looks like not(DRY) to me.

Best regards, Thushan

Thanks Zach for the insight into the problem.

IMO, except for the reason mentioned in the last paragraph, all reasons are due to internal issues of Rails, from which the programmer should be insulated. I think it's not good if you expect the programmer to cover up for issues you have inside the framework.

But you have a good point in the last paragraph (ie. just by looking at a model class, you will know all its relationships). That's good enough for me. :wink:

Best regards, Thushan