ERB不想在Rack App中呈现文件

时间:2012-04-27 01:53:01

标签: ruby templates rendering rack erb

当我使用erb方法时:

require 'erb'

def erb(template)
  path = File.expand_path("../views/#{template}", __FILE__)
  ERB.new(File.read(path)).result(binding)
end

然后使用a:

Rack::Response.new(erb('default.html.erb'))

它提出了一个Errno :: ENOENT。为什么是这样?谢谢!

1 个答案:

答案 0 :(得分:1)

看起来您的文件路径可能有误。检查以确保正确。