Rails association conventions

An-Chieh Kuo (郭安傑/關節)
2 min readJan 25, 2018

--

Notes about Rails association conventions.

If we have DB schema as below:

Conventions of “belongs_to” association will be like this:

Conventions of “belongs_to” association

Conventions of “has_many” association will be like this:

Conventions of “has_many” association

Conventions of “has_many :through” association will be like this:

Conventions of “has_many :through” association

I made a website for checking associations. Check it below!

English ver: https://kansetsu7.github.io/rails_association_checker/

Chinese ver: https://kansetsu7.github.io/rails_association_checker/index_tw.html

--

--