在 Rails 中渲染动态横幅的公共 html?
我想渲染特定的 HTML 片段来显示横幅,因为每个横幅都有不同的性质(一些图像,一些 Flash 等)。每个横幅文件都位于 app/public/banners/ 下。我尝试了很多方法,例如:
render :file => "/banners/somebanner.html"
但它无法找到该文件,因为 Rails 在 app/views 下查找。有什么想法吗?谢谢!
视图路径app/views中缺少模板banners/somebanner.html
I would like to render specific HTML snippets for displaying banners, because each banner has a different nature (some images, some flash, etc). Every banner file is under app/public/banners/. I tried many ways, like:
render :file => "/banners/somebanner.html"
But it can't locate the file, because Rails looks under app/views. Any ideas ? Thanks!
Missing template banners/somebanner.html in view path app/views
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我从来没有厌倦过,但刚刚发现 Google 上的这篇文章
看起来可能会有一些缓存副作用,即使在开发模式下
http://workingwithrails.com/forums/4-ask-a-rails-expert/ topic/1178-render-file-rails-root-public-layouts-mylayout-cached
你可能也想要:layout =>错误的
I've never tired it but just found this post on Google
looks like there might be some caching side-effects, even in development mode
http://workingwithrails.com/forums/4-ask-a-rails-expert/topics/1178-render-file-rails-root-public-layouts-mylayout-cached
also you probably want :layout => false with that
临时修复:
将“public/banners”移至“app/views/banners”,然后在“/public”中创建符号链接,以便我的团队可以添加新横幅
Temporary Fix:
Moved 'public/banners' to 'app/views/banners' and then made a synmlink in '/public' so my team can add new banners