Sinatra应用程序在运行时不启动 [英] sinatra app doesn't start on run
本文介绍了Sinatra应用程序在运行时不启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是Ubuntu 10.10/Ruby 1.9.2
无论我做什么,我都无法在本地计算机上启动Sinatra应用程序。
hello.rb:
require 'sinatra'
get '/' do
"Hello World!"
end
"$ruby hello.rb"和"$ruby-rubygems hello.rb"都会导致不执行任何操作的新提示。
有什么提示或指示吗?
推荐答案
这是在Ruby 1.9.2
上运行的Sinatra 1.0
中的已知问题;该问题已在Sinatra 1.1
Whichis just around the corner中修复。
使用enable :run
修复:
require 'sinatra'
enable :run
get '/' do
"Hello World!"
end
使用Ruby 1.9.2
+Sinatra 1.0
堆栈可能会遇到的另一个问题是,更改了Ruby 1.9.2
中Ruby脚本的默认加载路径,该路径不包括当前目录,因此视图在默认情况下不会按预期工作,请使用:
set :views, File.dirname(FILE) + "/views"
这篇关于Sinatra应用程序在运行时不启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文