Organizing Rails Model Files Discussion
Great episode, Collin: thank you
I also found the annotate output at the top of the file annoying, so my team now has annotate config set to output at the bottom of the file:
Annotate.set_defaults({
'position_in_routes' => "bottom",
'position_in_class' => "bottom",
'position_in_test' => "bottom"
})
Thanks, Terry! Glad you liked this one.
Thanks for sharing that annotate config! I've actually never looked into if there was an alternative to placing the comments at the top so this is great to know now.
I always wondered about good practices how to order things in my model. Thanks for that and the gotchas.
Nice one ! I do like to check Mastodon source code as reference too. For example, they've a lot of association on the Account model, and instead of bloating the model, they've defined a Account::Associations
module that they include. It allow them to keep associations well organized, with a small comment on related associations. See: https://github.com/mastodon/mastodon/blob/main/app/models/concerns/account/associations.rb