开发者

Render public html for dynamic banners in Rails?

开发者 https://www.devze.com 2022-12-28 02:51 出处:网络
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

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 v开发者_Python百科iew path app/views


I've never tired it but just found this post on Google

render :file => "#{RAILS_ROOT}/public/banners/somebanner.html"

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


Temporary Fix:

Moved 'public/banners' to 'app/views/banners' and then made a synmlink in '/public' so my team can add new banners

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号