Render a text string as a partial in Rails 3


I am storing customer-specific partials on S3. When I render the value of the S3 object, it renders as text. How can I render it so that it appears within my main layout?

Best Solution

Looks like I just need to:

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

And it works!

Update: Since 2013 rails changed

There is 3 different ways:

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`


Related Question