Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图render :file在我的视图中渲染一个 HTML 文件,但问题是,如果这个 .html 文件包含任何 ruby 代码,它最终会被执行,这是我试图避免的事情。
render :file
有没有办法做到这一点?
如果你想输出一个简单的文件,你可以这样做:
path = __FILE__ render text: File.read(path).html_safe
这会将当前文件作为输出写入。