DEV Community

roeihaviv
roeihaviv

Posted on

1

Associations

This rule helps me whenever I create direct and indirect associations:

For every forign key there should be a "belongs_to", and for every "belongs_to" there should be "has_many".

By following this rule it is much easier to keep track on all the associations, and quickly identify if something is missing.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay