I'm using Rails and I have methods for view, controller and model Because it became a matter of how to use it properly and define it Describe as a memorandum
Page display, page transitions, and user-entered information Has a role such as sending to the controller ** Presentation logic **
The word that goes into 〇〇 is ** business ** logic Image of data and data-related processing, processing to save and read in DB
・ If the same business logic is duplicated in View,
Wider range of changes and more costly
→ If you write in Model
, there is only one place to change
・ Because it is necessary to write a test via View It is costly to test all for the same business logic → If you write this in `Model, you only need one test
・ If the design changes frequently The change can have an impact on your business logic
View just displays! simple When writing logic, use Controller, Model, Helper, Decorator, etc. Use properly
In addition, I will add it later!
Field Rails https://techracho.bpsinc.jp/hachi8833/2018_05_07/55778 https://qiita.com/sumin/items/24689d0a5622f000a71f
Recommended Posts