我可以在Rails 3中将文本字符串渲染为部分字符串吗?

问题描述 投票:4回答:1

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

ruby-on-rails-3 partial-views
1个回答
17
投票

看起来我只需要:

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

它的工作原理!


更新:自2013年以来铁路发生了变

有3种不同的方式:

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

© www.soinside.com 2019 - 2024. All rights reserved.