Ruby on rails Rails Undefined方法在`lib`dir中包含模块时包括
我无法从我的Ruby on rails Rails Undefined方法在`lib`dir中包含模块时包括,ruby-on-rails,module,helper,Ruby On Rails,Module,Helper,我无法从我的libdir加载我的PactHelper模块 # lib/pact_helper.rb module PactHelper def so_something end end 及 #app/controllers/registrations_controller.rb 类注册控制器
lib
dir加载我的PactHelper
模块
# lib/pact_helper.rb
module PactHelper
def so_something
end
end
及
#app/controllers/registrations_controller.rb
类注册控制器<应用程序控制器
包括打包机
def新
...
结束
结束
返回#
有人能给我解释一下为什么没有包括我的模块吗?试试:
require 'pact_helper.rb'
以上:
class RegistrationsController < ApplicationController
类注册控制器
在:
注册\u controller.rb如果您想在rails应用程序中使用帮助程序,请将它们放入应用程序/帮助程序中,它们将自动被包括在内。如果要将它们放入lib dir,必须将lib dir添加到application.rb
config.autoload_path+=%W(#{config.root}/lib)
class RegistrationsController < ApplicationController