1
我成功使用了em-dir-watcher,如命令行的example.rb文件所示,但是我发现自己需要从另一个类调用一个方法,所以我选择了脚本/ runner改为路由,调用rails。在脚本/运行器中运行EventMachine
我复制/粘贴示例代码并置于self.methodName的内部和遇到的此错误:
MyApp的/供应商/轨道/ railties/LIB /命令/ runner.rb:48:未定义的方法`手表“对于EventMachine的:模块(NoMethodError)
即使我完全运行简单的类似:
def self.watcher
EM.run {
dw = EMDirWatcher.watch '.' do |paths|
paths.each do |path|
puts path
end
end
puts "Monitoring"
}
end
并调用脚本/亚军:
script/runner "require 'rubygems'; require 'em-dir-watcher'; Myclass.watcher"
我仍然得到错误。我究竟做错了什么?