我知道我可以在 Helper
中放置一个辅助方法helper
里面的类Rails 中的文件夹。然后可以在任何 View 中使用该方法。我知道我可以将方法放入 ApplicationController
class 并且该方法可以在任何 Controller 中使用。
将在 Controller 和 View 中经常使用的方法放在哪里合适?
最佳答案
您可以将其放入 Controller 并调用:
helper_method :my_method
从 Controller 。
关于ruby-on-rails - Rails 中的 Controller 和 View 中使用的辅助方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18775055/