How to return HTML directly from a Rails controller?

后端 未结 3 470
暗喜
暗喜 2020-12-02 18:00

One of my model objects has a \'text\' column that contains the full HTML of a web page.

I\'d like to write a controller action that simply returns this HTML direc

3条回答
  •  抹茶落季
    2020-12-02 18:30

    In latest Rails (4.1.x), at least, this is much simpler than the accepted answer:

    def show
      render html: '
    html goes here
    '.html_safe end

提交回复
热议问题