Ruby on rails NoMethodError(未找到R函数“get”)
我正在尝试使用RSRuby连接Ruby和R 在我的应用程序\u控制器中,我有以下内容:Ruby on rails NoMethodError(未找到R函数“get”),ruby-on-rails,ruby,r,nomethoderror,Ruby On Rails,Ruby,R,Nomethoderror,我正在尝试使用RSRuby连接Ruby和R 在我的应用程序\u控制器中,我有以下内容: def InitR @r = RSRuby.instance return @r end 当我作出以下决定时: @r = InitR() 它在浏览器中引发以下问题:R未找到函数“get” 在控制台中显示: NoMethodError (R Function "get" not found): app/controllers/application_controller.rb:6:in
def InitR
@r = RSRuby.instance
return @r
end
当我作出以下决定时:
@r = InitR()
它在浏览器中引发以下问题:R未找到函数“get”
在控制台中显示:
NoMethodError (R Function "get" not found):
app/controllers/application_controller.rb:6:in `InitR'
app/controllers/diagnostic_controller.rb:32:in `generatePdf'
正如我在一些帖子中看到的那样,我试图改变堆栈限制,但似乎没有任何效果
有人知道吗?
这就是我的代码在ApplicationController中的显示方式
class ApplicationController < ActionController::Base
protect_from_forgery
# Make R instance available to all
def initR
@r = RSRuby.instance
end
end
调用RSRuby.instance时引发异常这里有几个问题
@r.wilcox_text([1,2,3],[4,5,6])
好的,更新之后,initR函数似乎已经失效。设置@r=initR
,就像说@r=@r=RSRuby.instance
,例如,您已经调用了它两次。如果要使用该函数,请将其更改为
def initR
RSRuby.instance
end
然后可以调用@r=initR
此外,它还考虑了错误是否与R本身有关,即该错误不是Ruby错误,而是R错误。您是否可以尝试在rails控制台中运行generate函数中的步骤,这可能会突出显示哪个特定步骤失败。@为什么要在这里谈论堆栈限制?这个错误并不表明这一点。你能运行这个吗?例如
require'rsruby'@r=rsruby.instance@r.rnorm(100)
我可以从rails控制台毫无问题地运行这个代码。然而,在应用程序中,RSRuby.instance引发了一个ExceptionAnk,非常感谢您的回答。我已经试过了,但是它引发了同样的异常。你能从你的控制器发布更多的代码吗?这可能与上下文有关。我已找到解决此问题的方法。这与所选应用程序进程缺少所需的堆栈内存有关。在我的例子中,在生成应用程序进程之前,我必须运行以下命令:ulimit-s unlimited
。但我建议不要让它在生产中不受限制。@PawelBarcik,增加堆栈大小对我不起作用。。。你发现还有什么可以解决这个问题的吗?
def initR
@r = RSRuby.instance
end
def initR
RSRuby.instance
end