Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I 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?

like image 424
AKWF Avatar asked May 16 '11 20:05

AKWF


1 Answers

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`

Source https://github.com/rails/rails/issues/12374

like image 140
AKWF Avatar answered Sep 28 '22 06:09

AKWF