轨道 3 和Sinatra 集成问题
我正在尝试在 Rails 3 (v3.0.1) 应用程序中设置 sinatra 应用程序,但没有成功。 Sinatra gem (v1.1.0) 使用捆绑安装进行设置。
这就是我所拥有的。
lib 目录中的 customer_app.rb 类 -
class CustomerApp < Sinatra::Base
get "/test" do
"Hello World"
end
end
我的 routes.rb 文件包含 -
CustomerService::Application.routes.draw do
root :to => CustomerApp
end
我正在尝试的 URL 是 - http://localhost:3000/test
我收到此错误(在浏览器上)- 路由错误。没有路由匹配“/test”
,并且日志中出现此错误 - ActionController::RoutingError(没有路由匹配“/test”):
我缺少什么吗?
我还注意到,即使是简单的机架路线也不起作用 -
root :to => proc { |env| [200, {}, ["Welcome!"]]}
I am trying to set up a sinatra app inside my Rails 3 (v3.0.1) application, but having no success. Sinatra gem (v1.1.0) is setup using bundle install.
Here's what i have.
customer_app.rb class in lib directory -
class CustomerApp < Sinatra::Base
get "/test" do
"Hello World"
end
end
my routes.rb file contains -
CustomerService::Application.routes.draw do
root :to => CustomerApp
end
The URL i am trying is - http://localhost:3000/test
I get this error (on the browser) - Routing Error. No route matches "/test"
and this error in the log - ActionController::RoutingError (No route matches "/test"):
Is there anything I am missing??
Also I just noticed, even a simple rack route is not working -
root :to => proc { |env| [200, {}, ["Welcome!"]]}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,
root
关键字仅映射路径/
。因此,您想说的是,将对
/
的任何请求转发到可以处理/test
请求的CustomerApp
。您应该更改匹配过滤器。
The
root
keyword by default maps only the path/
.So you are trying to say, forward any request for
/
toCustomerApp
which can handle requests for/test
.You should change the match filter.