开发者

Using Ruport for the show view in RoR

开发者 https://www.devze.com 2023-02-10 15:54 出处:网络
Hy y\'all. I previously thank you for your answers. I\'m making a simple report with Ruport in RoR. Rails v: 2.3.5. Ruby v: 1.8.7.

Hy y'all. I previously thank you for your answers.

I'm making a simple report with Ruport in RoR. Rails v: 2.3.5. Ruby v: 1.8.7.

This is, practicly, mi report's code:

def setup self.data = Envio.report_table( :all, :conditions => [' id = ? ', :id ]) end

  formatter :pdf do
    build :list do
      pad(10) { add_text "Hoja de Salida" }
      draw_table data
    end
  end

What I need to do is to use this report in the show view in my app for the envio controller. For that I've modified my controller to this:

    def show
      pdf = EnvioReport.render_pdf
      send_data pdf, :type => "application/pdf",
                     :filename => "Salida.pdf" 
    end

And the error I'm getting is this one:

PDF Formatter requires column_names to be defined

Parameters:

{"id"=>"1"}

I've been struggling with this the last few days. Does anyone have a clue and tell me where'开发者_运维百科s is my mistake?

BTW: I'm using Rails 2.3.5 only for beeing able to use streamlined plugin


I finally stopped trying to do my report using Ruport when I found this:

http://www.brandensilva.com/rails/create-a-pdf-invoice-using-prawn-in-rails/

and this

http://railscasts.com/episodes/153-pdfs-with-prawn

By using prawn and prawnto It's more feasible to do some pdf reports. Now It's just about polishing my reports face.

I also tried to use Prince and princely but couldn't get it done.

I hope this will be usefull for someone else.

Conclusion 0: you better use prawn instead of Ruport. It has a very easy understanding syntax and it's usefull for quick, simple reports.

Conclusion 1: there's a lot more for newbies like me for pdf reporting in RoR than just Ruport (prawn + prawnto, prince + princely, jasper reports + ireport, PDF::Writer).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号