activerecord - Rails - Has Many multiple nested association -
let's have 3 models: a, b, c.
class has_many :bs end class b has_many :cs end
what easiest way declare association in can access c's has through b? can call a_object.c_objects
. dumb question, i'm kinda stuck. thanks!
if have established associations
a has many b, , b has_many c
then set up. thing adding following code (no database changes needed):
class has_many cs, through: :bs end
and use a_object.c_objects
.
Comments
Post a Comment