【发布时间】:2015-03-17 06:19:36
【问题描述】:
我正在使用 Rails 4.1 进行开发。
我有以下模块(app/policies/model_filters/helpers.rb:
module ModelFilters
module Helpers
def allow(record, action)
end
end
end
我将它包含在我的app\controllers\application_controller.rb:
class ApplicationController < ActionController::Base
include ModelFilters::Helpers
在我想使用它们的课程中(app\bar\foo.rb):
class Foo
include ModelFilters::Helpers
方法包含正确,但在上述模块中似乎没有 Devise 助手;当我开始我的规格测试时,我得到:
undefined local variable or method 'current_user' for #<Foo...
# ./app/policies/model_filters/helpers.rb:5:in `allow'
# ./app/bar/foo:13:in `recent'
您知道如何让 Devise 助手在模块中或通常在控制器外部可见吗?
谢谢!
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 devise helpers