中级Ramaze路由请帮忙
第 1 部分:
我调用了 layout(:default){|path,wish| Wish !~ /rss|atom|json/}
但对 /foo/bar.json
的请求似乎认为 wish
是 html
并使用该布局。我该如何解决这个问题?
第 2 部分:
我想路由 /path/to/file.ext
,以便它调用映射到 /path
的控制器上的方法 to
并在制定回报时使用ext
。有没有比将 'file.ext' 传递给 to
方法、解析它并执行案例更好(更优雅)的方法?如果我写下“如何使用 Ramaze 进行 REST?”,这个问题会更简洁。似乎有一个 Google 网上论坛对此问题的答案,但由于某种原因我无法访问它。
Part 1:
I have a call to layout(:default){|path,wish| wish !~ /rss|atom|json/}
but requests to /foo/bar.json
seem to think wish
is html
and uses the layout anyway. How can I fix this?
Part 2:
I want to route /path/to/file.ext
so that it calls the method to
on the controller mapped to /path
and uses ext
when formulating the return. Is there a better (more elegant) way to do this than passing the 'file.ext' to the to
method, parsing it, and doing cases? This question would have been more succinct if I had written, how does one do REST with Ramaze? There appears to be a Google Groups answer to this one, but I can't access it for some reason.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您请求
/path/to/bar.json
时,此控制器返回纯 JSON,并在您请求/path/to/bar
时使用布局+视图包装(Ramaze 没有默认布局设置,本例中的布局来自于Controller父类)。This controller returns plain JSON when you request
/path/to/bar.json
and uses the layout+view wrapping when you request/path/to/bar
(Ramaze has no default layout setting, the layout in this example comes from the Controller parent class).