4

我目前正在尝试在服务对象中使用设计助手

class ServiceObject
    include Devise::Controllers::Helpers

但我明白了

undefined method `helper_method' for ServiceObject:Class

知道如何在服务对象中使用这样的助手吗?

4

2 回答 2

2

问题是这helper_method是一个由 定义的方法ActionController::Base。因此,包含该模块仅适用于它们的子类。

如果助手已经包含在您的中,ApplicationController您可以简单地使用ApplicationController.new.method_to_call

于 2015-06-27T19:05:04.517 回答
0

尝试使用presentar。可能您可以使用装饰器宝石。这样您就可以保持您的表示层独立,并且可以轻松地使用任何级别的框架堆栈。

于 2015-06-27T19:26:46.437 回答