0
我有此視圖new.html.erb
視圖紅寶石:控制器在是helper_method未示出on Rails的
控制器是articles_controller.rb
:
class ArticlesController < ApplicationController
def new
y = R.pull "capture.output(summary(rnorm(10)))"
puts y
end
helper_method :test
def test
sample_size = 10
R.eval "x <- rnorm(#{sample_size})"
R.eval "summary(x)"
R.eval "sd(x)"
y = R.pull "capture.output(summary(rnorm(10)))"
puts y
end
end
爲何輸出(這裏示出:ruby in web)不包括test
方法的結果?
所以...我得到了輸出...但是正如你所說...輸出不是很好....如何讓它更像桌子?或至少只是ascci是好的....,謝謝你... –
好吧你打印到一個HTML頁面,你需要解析它,並用html和erb寫它。你可以嘗試在它周圍放置一個'pre'標籤 – PhilVarg
'pre'標籤在控制檯中不會顯示...我只想將控制檯的格式添加到網絡中......而我仍然不會理解 –