jjzjj

TestFunctions

全部标签

ruby-on-rails - rails : I can't call a function in a module in/lib - what am I doing wrong?

我有一个模块保存在/lib中作为test_functions.rb看起来像这样moduleTestFunctionsdefabcputs123endend进入ruby​​脚本/运行程序,我可以看到该模块正在自动加载(良好的配置约定等等......)>>TestFunctions.instance_methods=>["abc"]所以方法是已知的,让我们尝试调用它>>TestFunctions.abcNoMethodError:undefinedmethod`abc'forTestFunctions:Modulefrom(irb):3没有。这个怎么样?>>TestFunctions::a