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

AKW*_*KWF 4 partial-views ruby-on-rails-3

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

AKW*_*KWF 17

看起来我只需要:

render :text => myTextFromS3, :layout => true
Run Code Online (Sandbox Code Playgroud)

它的工作原理!


更新:自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`
Run Code Online (Sandbox Code Playgroud)

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