How to render erb template to string inside action?

前端 未结 4 1799
囚心锁ツ
囚心锁ツ 2020-12-16 14:52

I need a string of html (something like \"Hello World\") for faxing purpose.

I wrote it into a seprat

4条回答
  •  猫巷女王i
    2020-12-16 15:43

    The reason is you cannot render or redirect inside the same action more than once at a given time.

    But in your code, you have both render and redirect. I think in your controller you can use simply only the render, assuming you don't need any json output.

    Try this

    def create
      @order.save   
      render(:partial => 'fax')
    end
    

    I haven't tested this, but I guess you get the idea :), and think about a way to handle errors as well (in case order didn't save).

提交回复
热议问题