undefined method `border_width=' for #<Prawn::Table:0xac1af5c>

805 views
Skip to first unread message

Arthur Martins

unread,
Feb 10, 2012, 12:53:34 PM2/10/12
to Prawn
I'm using praw (0.12.0), third rails, ruby 1.9.2, below is my code in
a template: sales.pdf.prawn

items = @order.cart.line_items.map do |item|
[
item.product.name,
item.quantity,
number_to_currency(item.unit_price),
number_to_currency(item.full_price)
]
end

pdf.table items,
:row_colors => ["FFFFFF","DDDDDD"],
:border_width => 0,
:headers => ["Product", "Qty", "Price" , "Full Price"]


The following errors are displayed:::::::::

undefined method `border_width=' for #<Prawn::Table:0xac1af5c>
undefined method `headers=' for #<Prawn::Table:0xa827a08>

Brad Ediger

unread,
Feb 10, 2012, 12:59:17 PM2/10/12
to prawn...@googlegroups.com
On Fri, Feb 10, 2012 at 11:53 AM, Arthur Martins <br.a...@gmail.com> wrote:
> I'm using praw (0.12.0), third rails, ruby 1.9.2, below is my code in
> a template: sales.pdf.prawn
>
> pdf.table items,
>  :row_colors => ["FFFFFF","DDDDDD"],
>  :border_width => 0,
>  :headers => ["Product", "Qty", "Price" , "Full Price"]

You're using Prawn's old table API. Please check out Prawn's manual
and/or the source code to learn about the new API:

http://prawn.majesticseacreature.com/manual.pdf

https://github.com/sandal/prawn/blob/master/lib/prawn/table.rb
https://github.com/sandal/prawn/blob/master/lib/prawn/table/cell.rb

In short: You'll need to move the headers in as the first row of your
data array and pass :headers => true instead, and :border_width is now
a cell style, so you can at the least pass :cell_style =>
{:border_width => 0}. See the manual and the code for more details.

-be

Reply all
Reply to author
Forward
0 new messages