我能在Rails 3中将文本字符串呈现为部分吗?

8

我正在将客户特定的部分存储在S3上。当我渲染S3对象的值时,它呈现为文本。如何使其呈现在我的主布局中?

1个回答

21

看起来我只需要:

render :text => myTextFromS3, :layout => true

它有效!


更新: 自从2013年,Rails已经更改

有三种不同的方式:

render html: '<strong>HTML String</strong>' # render with `text/html` MIME type

render plain: 'plain text' # render with `text/plain` MIME type

render body: 'raw body' # render raw content, does not set content type, inherits 
                        # default content type, which currently is `text/html`

来源 https://github.com/rails/rails/issues/12374


Rails 似乎会自动替换掉这部分的 <>。 - shevy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接