开发者

rails HABTM migrations

开发者 https://www.devze.com 2023-01-12 07:14 出处:网络
From a practical and best practices perspective, should rails models that have HABTM association also have a defined model for example users_groups.rb.So, should you

From a practical and best practices perspective, should rails models that have HABTM association also have a defined model for example users_groups.rb. So, should you


script generate model ...

or simply


script generate migration ...

开发者_JS百科

On one hand the join table is simply two fields and shouldn't have any methods of its own, on the other hand, in rails (model = table). So would it be wise to have it defined in models as well as in migrations?


Hi as for me if you have has_and_belongs_to_many you don't need any model but if you use has_many+:through you'll need one

0

精彩评论

暂无评论...
验证码 换一张
取 消