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 8119203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:44:08+00:00 2026-06-06T04:44:08+00:00

I have a custom controller action as listed below. I have a form with

  • 0

I have a custom controller action as listed below. I have a form with checkboxes that allow me to print the selected items by writing them to a pdf file using Prawn. Any Ideas?

I’m getting the following error.

AbstractController::DoubleRenderError (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.

Here is the relevant part of the controller

class ShipmentsController < ApplicationController
  autocomplete :client, :name, :full => true
  autocomplete :product, :product_name, :full => true, :extra_data => [:product_code, :miller_product_code]

  respond_to :js, :html
def index
  if params[:status]
    @openshipments = Shipment.where(:status => params[:status]).search(params[:search1]).order(sort_column + " " + sort_direction).page(params[:page])
  else
    @shipments = Shipment.search(params[:search]).order(sort_column + " " + sort_direction).page(params[:page])
  end
end
def create
  ...
end
def edit
  ... 
end
def update
  ... 
end
def destroy
  ...
end

def print_open
  @printshipments = Shipment.find(params[:open_shipment_ids])

  respond_to do |format|
    format.pdf do
      @printshipments.each do |shipment|
        pdf = Prawn::Document.new
        pdf.text "bill_of_lading_#{shipment.bill_of_lading}"
       #removed send_data pdf.render, filename: "bill_of_lading_#{shipment.bill_of_lading}"
        File.open("public/bill_of_ladings/bill_of_lading_#{shipment.bill_of_lading}.pdf", "wb") { |f| f << pdf.render }
        shipment.update_attribute(:status, "PRINTED")

      end
    end
  end
  redirect_to shipments_path
end

EDIT:
I can get rid of the error by removing the send_data line, however I can’t get the form to redirect to the page I want. It only wants to render the javacript in the directory, possibly because this is a remote form. I am calling the print_open through a form_tag that uses the following route.

  get '/shipments/status/:status' => 'shipments#index'

When I use the redirect_to shipments_path at the end of my print_open method, It renders the view, but the url in the browser still reads as:

http://localhost:3000/shipments/status/open

instead of:

http://localhost:3000/shipments
  • 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-06T04:44:10+00:00Added an answer on June 6, 2026 at 4:44 am

    Since you’re looping over an array and calling send_data on each element, it’s possible you’re calling send_data more than once. That would give you the exception that you’re receiving.

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

Sidebar

Related Questions

I have a segue (called ToSettingsSegue ) that pushes a custom view controller (
I have a custom UINavigationController that draws a custom background. That navigation controller is
In a word, how? I have a view controller that creates a few custom
I have a controller POST action that redirects to a GET method using RedirectToAction.
I have a controller action that returns some JSON results to the jQuery Full
I have a controller and action which I'm accessing through a custom URL. The
I hate the codeigniter custom urls where it's: domain.com/controller/action/id How can I have it
I have a table view controller with custom cells. In those cells i added
I have an app with a custom UITabBarController that contains five view controllers. Within
I have custom classes that I currently instantiate within App.xaml as resources. I want

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.