DRY Controllers in Rails 3.2

前端 未结 3 2240
有刺的猬
有刺的猬 2021-02-15 15:00

Following code climate analysis, I found that my controllers are not DRY as it could be. The methods like:

   def index
    @animals = current_user.animals.valid         


        
3条回答
  •  长情又很酷
    2021-02-15 15:28

    Ken Li is right, over abstraction is not a good thing and in this case a little unnecessary, though if you do have repeated code in your controllers you can use the Before, Around and After filters to DRY out the code.

提交回复
热议问题