Rails - How to organize model code?

I'm sorry if this seems more simplified, but I wonder what the general thing is in how to organize the model code.

Association declarations, if you think that certain types of associations should be declared before others, accepts_nested_resource declarations, checks, user checks, protected and private methods, module inclusion, anything and everything.

I have heard of strange goths that can occur with the ordering of various callbacks and associations, but I have never seen them all documented anywhere.

Obviously, there will be some controversy, and there probably isn't a true way, but this can be expected. I am very curious to find out how other people organize their code. Thank.

+3
source share
1 answer

I use this simple three-step order:

1) Relations 2) Checks 3) Methods

I don’t think I ever put anything after methods or before relationships.

+2
source

Source: https://habr.com/ru/post/1758642/


All Articles