Ruby ERB不希望在Rack App中渲染文件

Ruby ERB不希望在Rack App中渲染文件,ruby,templates,rendering,rack,erb,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 然后使用: Rack::Response.new(erb('default.html.erb')) 它会引发一个Errno::enoint。为什么会这样?谢谢 看起来您的文件路径可能有误

当我使用erb方法时,使用:

require 'erb'

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

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

它会引发一个Errno::enoint。为什么会这样?谢谢

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

您的右侧,它正在我的目录中查找
lib/views
,两个
。/
起了作用。