【发布时间】:2013-03-18 10:49:30
【问题描述】:
我正在尝试使用 RSRuby 连接 Ruby 和 R。
在我的 application_controller 我有以下内容:
def InitR
@r = RSRuby.instance
return @r
end
当我制作时:
@r = InitR()
它在浏览器中引发以下内容:R Function "get" not found
并在控制台中显示:
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
这里是 DiagnosticController,我想在其中使用实例:
def generatePdf
project = Project.find(session[:project_id])
pdf = Prawn::Document.new
sentence = RSentence.find_by_name("library").content.gsub("LIBRARY", "lattice")
pdf.text sentence
pdf.render_file project.name.to_s + ".pdf"
@r = initR
@r.eval_R(sentence)
redirect_to :controller => "diagnostic", :action => "index"
end
调用 RSRuby.instance 时引发异常
【问题讨论】:
-
@为什么要在这里谈
stack limit?错误不建议这个..你可以运行这个例如require 'rsruby' @r = RSRuby.instance @r.rnorm(100) -
我可以从 rails 控制台毫无问题地运行该代码。但是,在应用程序中,RSRuby.instance 引发了异常
标签: ruby-on-rails ruby r nomethoderror