Rails Model, View, Controller, and Helper: what goes where?

后端 未结 10 1021
不思量自难忘°
不思量自难忘° 2020-11-30 15:59

In Ruby on Rails Development (or MVC in general), what quick rule should I follow as to where to put logic.

Please answer in the affirmative - With Do put this h

10条回答
  •  感动是毒
    2020-11-30 16:58

    In simple terms, generally, Models will have all the codes related to table(s), their simple or complex relationships (think them as sql queries involving multiple tables), manipulation of the data/variables to arrive at a result using the business logic.

    Controllers will have code/pointers towards the relevant models for the job requested.

    Views will accept the user input/interaction and display the resultant response.

    Any major deviation from these will put unwanted strain on that part and the overall application performance may get impacted.

提交回复
热议问题