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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:59:02+00:00 2026-05-27T11:59:02+00:00

In a ruby on rails application prawn ,prawnto is used to generate pdf raises

  • 0

In a ruby on rails application prawn ,prawnto is used to generate pdf raises some error..

 def generate_report

    generate_report = params[:report_type]

# puts(generate_report)

if generate_report == "1"
       # get count of all successful downloads
  @total_downloads=StatisticDownload.where("DownloadSuccess=?","1").count
  #puts(@total_downloads)
  # get all downloads grouped by date
  @downloads  = StatisticDownload.select("date(Date) as downloaded_date, count(id) as count").where("DownloadSuccess=?","1").group("date(Date)")
  respond_to do |format|
    format.pdf { render :layout => false }
   end  
         end 

Code in generate_report.pdf.prawn

        pdf.move_down(30) 
      book =  @downloads.map do |item|
     [
       item.downloaded_date,
         item.count
     ]
      end
         pdf.table book, :border_style => :grid,
        :row_colors => ["FFFFFF", "DDDDDD"],
        :headers => ["downloaded_date", "count"],
        :align => { 0 => :left, 1 => :right, 2 => :right, 3 => :right }

/admin/generate_report gives a blank page as output

/admin/generate_report.pdf gives an error

  You have a nil object when you didn't expect it!
  You might have expected an instance of Array.
  The error occurred while evaluating nil.map
  Extracted source (around line #2):

     1: pdf.move_down(30) 
      2: book =  @downloads.map do |item|
      3:  [
    4:   item.downloaded_date,
     5:   item.count

how can i rectify this error

  • 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-05-27T11:59:03+00:00Added an answer on May 27, 2026 at 11:59 am

    May be worth going to http://railscasts.com/episodes/153-pdfs-with-prawn-revised and following the tutorial, you will have to subscribe to watch if you haven’t got a pro subscription though.

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

Sidebar

Related Questions

I'm developing a Ruby on Rails application need some advanced search engine functionality: specifically,
I've created some resources in my Ruby on Rails application: localhost/admin/books localhost/admin/users localhost/admin/... Now
My Ruby on Rails application uses the following controller code to generate a sitemap.xml
In my Ruby on Rails application I want to show 404 error page instead
After our Ruby on Rails application has run for a while, it starts throwing
I have a ruby on rails application and it would be nice to see
I'm developing a Ruby on Rails application that needs to allow the user to
says if i develop a Ruby on Rails application using Rails 2.3.2, will that
I am trying to deploy my Ruby on Rails application on Media Temple. The
I have to to deploy a Ruby on Rails application to an tomcat application

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.