我最近用 eruby 配置了 Apache 并运行了一些 rhtml 页面。我有一个globalfunctions.rb
文件,我希望该文件可供我在网站上运行的所有页面使用。
但是,我有一个问题:在 rhtml 中放置一个 require 语句会使其中断并返回错误 500。这是页面的代码:
<html>
<head>
<title>Home | Quantum Software</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<%
require './globalfunctions.rb'
%>
<div class="contentBox">
</div>
</body>
</html>
和全局函数文件:
def get_file_name()
return File.basename(__FILE__)
end
def new_nav_link( target, title )
currentFileName = get_file_name()
if target == currentFileName
puts %Q@<a href="#{target}" class="selected">#{title}</a>@
else
puts %Q@<a href="#{target}">#{title}</a>@
end
end
最后,这是 error.log 的最后几行:
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] :
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] no such file to load -- ./globalfunctions.rb
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] (
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] LoadError
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] )
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] --- generated code ---
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "<html>\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "<head>\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "\\t<title>Home | Quantum Software</title>\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "\\t<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"style.css\\" />\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "</head>\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "<body>\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103]
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] require "./globalfunctions.rb"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "<div class=\\"contentBox\\">\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "</div>\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "</body>\\n"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] print "</html>"
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] ----------------------
[Fri Apr 27 23:22:59 2012] [error] [client 174.252.185.103] Premature end of script headers: eruby
[Fri Apr 27 23:23:24 2012] [error] an unknown filter was not added: includes
[Fri Apr 27 23:23:24 2012] [error] an unknown filter was not added: includes
[Fri Apr 27 23:24:04 2012] [error] an unknown filter was not added: includes
[Fri Apr 27 23:27:03 2012] [error] an unknown filter was not added: includes
提前感谢您的帮助。