Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9157615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:04:15+00:00 2026-06-17T13:04:15+00:00

I need a string of html (something like <html><body>Hello World</body></html> ) for faxing purpose.

  • 0

I need a string of html (something like "<html><body>Hello World</body></html>") for faxing purpose.

I wrote it into a seprate erb file: views/orders/_fax.html.erb ,
and try to render the erb in action: html_data = render(:partial => 'fax').

Here is part of the controller that raises the issue:

  respond_to do |format|
      if @order.save   
        html_data = render(:partial => 'fax')
        response = fax_machine.send_fax(html_data)
        ......

        format.html { redirect_to @order, notice: 'Order was successfully created.' }
        format.json { render json: @order, status: :created, location: @order }
      else  
        format.html { render action: "new" }
        format.json { render json: @order.errors, status: :unprocessable_entity }
      end
    end

It gave me an AbstractController::DoubleRenderError as below:

AbstractController::DoubleRenderError in OrdersController#create

Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".

How to solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:04:16+00:00Added an answer on June 17, 2026 at 1:04 pm

    If you only need the rendered HTML, and don’t need any functionality from the controller, you might try using ERB directly within a helper class, eg.:

    module FaxHelper
    
      def to_fax
        html = File.open(path_to_template).read
        template = ERB.new(html)
        template.result
      end
    
    end
    

    The ERB docs explain this in more detail.

    EDIT

    To get the instance variables from the controller, pass the binding into the result call, eg:

    # controller
    to_fax(binding)
    
    # helper class
    def to_fax(controller_binding)
      html = File.open(path_to_template).read
      template = ERB.new(html)
      template.result(controller_binding)
    end
    

    Note: I’ve never done this, but it seems workable 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to insert an HTML string into the <head> tag of the current
I need a string splitted into groups of characters in ActionScript like this: var
I have an ASCII String, with HTML entities, like: &agrave; &uml; &ccedil; I need
In my JavaScript code I have a string that contains something like: var html
I need to pass a <![cdata[something-html-formatted]]> to a xml file where I parse it
I have an html string I'd like to dump directly into an element. This
I have a string containing HTML and I need to replace some words to
In ASP.NET Application. I need to return string (which contains all necessary html tags)
I have HTML pages as String in Java and I need to extract the
I have a string of text that contains html, and I need to extract

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.