ruby - In Rails, can I set a has_many relation on a model from another model? -


is there way can set both halves of belongs_to/has_many relation in 1 of models? want like:

class < activerecord::base end  class b < activerecord::base   belongs_to :a   a.has_many :b end 

obviously doesn't work (or have used it) hope explains mean...

i'm not sure why you'd want to, assuming have great reason...

has_many class method defined in activerecord::base calling a.has_many :b should work.

you might have issues in development loading order. if load example gave , called a = a.new, class b has never been loaded, a has no idea a has many b. in production, entire class list loaded on start, won't problem. in development can around using require statement, however, coupling 2 files pretty strongly.

i haven't tried it, in theory, that's thing can think of preventing setup above working.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -