Rails: Model instance method or helper method?

前端 未结 2 826
别那么骄傲
别那么骄傲 2021-01-04 09:40

By convention, should the following be defined as an instance method of my model or a helper method?

# app/models/user.rb
class User < ActiveRecord::Base
         


        
2条回答
  •  半阙折子戏
    2021-01-04 10:29

    Everything directly related to your model should stay in your model.

    This way, you keep coherent logic and tests.

提交回复
热议问题