Should Rails helpers assume an instance variable exists or should they receive them as parameters?

后端 未结 4 1876
太阳男子
太阳男子 2020-12-13 17:59

I\'m wondering if there\'s a specific programming principle (Demeter?) that supports the idea that Rails helpers should never use controller instance variables, rather, they

4条回答
  •  长情又很酷
    2020-12-13 18:14

    I'd say you should always pass the variables explicitly to your helper for 2 reasons:

    • you control exactly what you do

    • above all, you can test your helper

提交回复
热议问题