EzDevInfo.com

ruport

Ruby Reports : Making your reporting life suck less, through Ruby

Underline in Ruby Report

Hey all,
I'm trying a very simple thing here in Ruport but I don't seem able to get it working.
All I want is underline a part of a text.
I already have the substring that I want to underline, because i thought <u></u> would do the trick (<i> and <b> work)
Anybody got a working solution for this?
Thanks!


Source: (StackOverflow)

Rails Ruport using SQL

Guys I'm using Ruport gem for Ruby Reporting, I gone through basic coding and configuration as follows

class Project < ActiveRecord::Base
  acts_as_reportable
end

and in IRB console i tried as follows

irb(main):001:0> puts Project.report_table

and it's working fine to me.

Problem is instead of Model, how to write my own queries with SQL and add that to Ruport table object?


Source: (StackOverflow)

Advertisements

How to Group by Day with Ruport / Ruby on Rails?

I'm trying to evaluate Ruport for use in my Rails app, but am not sure how to take a series of records with date/time stamps and group them via Ruport's grouping functions.

I'm open to other/better methods to do this same grouping if Ruport doesn't make sense.


Source: (StackOverflow)

Conflicting column names in Ruport report table

When using Ruport to make a CSV file for entities containing the same entities, the generated column names create conflicts, causing Ruport to show only the first occurence of this column(s). To make this abstract explanation more clear and less complicated, an example:

My class Zone inherits from ServerUnitConfig, which has a :belongs_to to a ServerUnit. So Zone has for example server_unit.su_name as a field. Zone also has a :belongs_to for Domain, which also inherits from ServerUnitConfig.

I want both to be included in my Ruport and to do this I have the following :include argument for my report_table of Ruport:

{            
    :server_unit => {:only => 'su_name'}, 
    :domain => {:include => {:server_unit => {:only => 'su_name'}}, :only => {}
}

Reporting this with Ruport in a CSV file, gives a report showing only the server_unit.su_name column of server_unit not the one of Domain. Normally also the server_unit.su_name should be shown, but since Ruport only shows the field name and its parent, both cases show server_unit.su_name and this gives conflicts.

I would suggest to give a custom name to the field in the include, but I don't know how. An other idea, if it would be possible, is to tell Ruport one or the other way it is no problem to have identical column names, but I don't think that is possible. Has anybody an idea to solve this problem? It would help me a lot!

Thanks

Daan


Source: (StackOverflow)

How to include the ruport/acts_as_reportable gems for JRuby using Warbler?

I am using JRuby 1.4.0 and want to use Ruport to make CSV files. This perfectly works until I make a war-file from it with warbler to put it on a server.

When I add the following code to environment.rb, JRuby complains there is No such file to load -- 'ruport'

 config.after_initialize do 
    require 'ruport' 
    require 'ruport/acts_as_reportable' 
  end

It works perfect locally, since I installed ruport and acts_as_reportable through gem install ..., but now I want to do it on a tomcat server and I've heard you can just add them to your gems folder to use it (does this need installation/configuration?).

I also added the needed gems with dependencies to the warble adding the following lines to warble.rb:

config.gems = ["ruport", "acts_as_reportable", "activerecord-oracle_enhanced-adapter", "rails", "rack"]

It still gives the same problem. All I found googling is the you should add config.gem 'acts_as_reportable', :lib => 'ruport/acts_as_reportable' to warble.rb, since the AAR gem is required that way. The problem is my JRuby version is only 1.4.0 and complains config.gem is a private method call and this only seems to work with more recent versions of JRuby.

Thanks!


Source: (StackOverflow)

Newbie - trying to save a datagrid to pdf

I'm using the gem datagrid to display some data. I would like to use ruport to output the data to pdf.

I added this button to my controller.rb=

<%= button_to "PDF", {:controller => :admin_reports, :action => :worequest_pdf }%>

I have this route=

resources :admin_reports do
post :worequest_pdf, :on => :collection

end

And this in the admin_reports_controller.rb=

 def worequest_pdf
f = File.new("worequest.pdf", "w")
f.write Ruport::Data::Table(:column_names =>report.header, :data => report.rows).to_pdf
f.close

end

But, it doesn't work - any ideas? I get:

undefined local variable or method `report' for #<AdminReportsController:0x007fc463566218> 

Source: (StackOverflow)

Ruport - undefined method `each' for "":String

sorry for my english.

I am following this tuto: http://ruportbook.com/printable_documents.html, the first example, but I get undefined method `each' for "":String all the time, I created a new file with this code:

class MultiTableController < Ruport::Controller    
  stage :multi_table_report    
  class PDF < Ruport::Formatter::PDF    
    renders :pdf, :for => MultiTableController    
    build :multi_table_report do
      data.each { |table| pad(10) { draw_table(table) } }
      render_pdf
    end    
  end    
end

Then, in an existing controller named workers_controller.rb I put the next action:

  def index_report
    t1 = Table(%w[a b c]) << [1,2,3] << [4,5,6]
    t2 = Table(%w[a b c]) << [7,8,9] << [10,11,12]
    pdf = MultiTableController.render_pdf(:data => [t1,t2])
  end

I added this route to routes.rb of course.

then, I get this error on my browser:

undefined method `each' for "1":String

But the error doesn't only occur with this example, I have tried many others examples and I get the same error.

Some help? Thks in advance! Regards.


Source: (StackOverflow)

Want a sample step by step example of Rails ruport

I watched the ruport website ,

api documentation and other stuff ,

But was not able to understand how to use it .

I want a simple sample example with steps of explanation

thanks


Source: (StackOverflow)

How do I programatically override the formatter of a Ruport data table?

I have a pretty straight-forward Ruport setup in my Rails app, where the Ruport controller is passed a Report::Data::Table instance:

class Reporter < Ruport::Controller
  stage :headline, :data, :footer
  required_option :report

def setup
    report_klass = options.report.report_model
    report_klass ||= Report
    self.data = report_klass.send(:report_table_by_sql, options.report.query)
  end
end

The Data::Table instance that is stored in data uses Ruport::Data::Table as its delegated controller when asked to render, so that's what gets called when I later call

output << data.to_html

How can I tell data to delegate its rendering methods to the Reporter class, so all my hook overrides can live in one place?


Source: (StackOverflow)

How to store ruport table data object in a database?

I intend to store a nightly build of report data in a DB and then use formatters when a user requests for a report in real-time.

A few clues... The Ruport::Data::Table object - that contains the data - is a collection of Ruport::Data::Record objects, accessible via the 'data' attribute i.e.

Ruport::Data::Table object

*=> Ruport::Data::Table:0xb6455680 @column_names=[], @record_class="Ruport::Data::Record", @data=[]*

The Ruport::Data::Record object contains the 'data' hash which needs to go into the DB

Ruport::Data::Record:0x7ff138104c90 @data={}, @attributes=[]

I'm using Rails and ActiveRecord

How can I achieve this?


Source: (StackOverflow)

Text Formatting in Ruby (For Packing Slips)

I need to generate formatted text packing slips for a Ruby on Rails project I'm working on. I'm considering using Ruport or just formatting it myself in a string and outputting it to text. The only challenge is justifying all of the output appropriately. It needs to look something like this, always aligned properly. Any recommendations?

Company Name
(T) 1-800-123-1234
(E) info@company.com

BILL TO: CUSTOMER NAME                   SHIP TO: CUSTOMER NAME
123 Some Street                          321 Some Street
Address etc.                             Address etc.

Date: 2010-03-12 16:30
Payment Number: 1234-123456

LN  NAME             SKU           DESCRIPTION             QTY    PRICE      TOTAL
----------------------------------------------------------------------------------
001 Product name     GUDB 012 HGQ  product description     2      52.99     105.98
         - Color

Source: (StackOverflow)

How to use will_paginate gem with ruport gem? in Rails 4

Gem's

gem "ruport", "1.6.3", :path => "vendor/gems/ruport-1.6.3"
gem "acts_as_reportable", "1.1.1", :path => "vendor/gems/acts_as_reportable-1.1.1"
gem 'will_paginate-bootstrap'

I am using ruport gem for generating the reports, from ruport gem reports are coming in table format.

on that table i need to implement pagination with will_paginate-bootstrap gem.


Source: (StackOverflow)

Resolving a class name conflict in a Rails application

I have been building a Rails application that performs accounting functionality. As part of this, I have a model with the class name Transaction. So far so good, I have been building this functionality for a month or so, and everything is working as expected.

Until now...

I have just discovered some older reporting functionality that was developed months ago using the Ruport library has stopped working. It appears that Ruport, when generating PDFs, requires a library that also has a class/module named Transaction.

TypeError in Admin/team reportsController#generate
Transaction is not a module

...

This error occurred while loading the following files:
  pdf/writer
  transaction/simple

So, I'm looking for a quick fix here. One that hopefully doesn't involve renaming my Transaction model and refactoring the last few weeks worth of code.

Looking forward to some clever suggestions :)


Source: (StackOverflow)

Rails, two dimensional table, pivot, nested hash loops

I am building grade-book report - a two dimensional table that shows lesson names going horizontally and a list of students going vertically.

Student Name | LessonID x | LessonID x | LessonID x          
Joe                 95%        95%
Mary                80%        80% 
Sam                 80%                    80%

My data is in a table that has these fields:

student_id, lesson_id, grade_in_pct, grade_in_pts, grade_high, grade_low, grade_median

The total number of students and lessons is not fixed.

I considered using ruport/acts_as_reportable or mysql pivot procedure, however it looks like the pivot only gives me one dimension. So that's not going to work, because in my view I want to add mouse-over features and conditional formatting to show more info on each grade.

So I think my only option is to generate a nested hash and then loop through it in the view. What are your thoughts? Could someone suggest a way to build a nested hash? Would it be too processor intensive to loop through 250 rows (~50 students, 5 lessons each)?

I am stuck. Please help. Thanks!


Source: (StackOverflow)

how to config ruport in the environment.rb

i have installed ruport gem along with its ruport-utils packages and act_as_reportable gem too.... e

"Ash::Application.initialize!

Rails::Initializer.run do |config| config.after_initialize do require "ruport" end end" when executing this in the environment.rb file... it shows this "

c:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:63:in `inherited': You cannot have more than one Rails::Application (RuntimeError)" what am i doing wrong.... can somebody help me with properly configuration method of ruport.


Source: (StackOverflow)