基于 Railscasts 的 Prawn 剧集,我想添加这样的行:
def line_items
move_down 20
table line_item_rows do
row(0).font_style = :bold
columns(1..3).align = :right
self.row_colors = ["DDDDDD", "FFFFFF"]
self.header = true
end
end
def line_item_rows
[["Product", "Qty", "Unit Price", "Full Price"]] +
@order.line_items.map do |item|
[item.name, item.quantity, price(item.unit_price), price(item.full_price)]
end
end
我想在“@order.line_items”行之后动态添加行,但我不知道该怎么做,然后我尝试了:
def line_item_rows
[["Product", "Qty", "Unit Price", "Full Price"]] +
@order.line_items.map do |item|
[item.name, item.quantity, price(item.unit_price), price(item.full_price)]
end
@order.other_line_items.map do |item|
[item.name, item.quantity, price(item.unit_price), price(item.full_price)]
end
end
但当然它不起作用。你知道怎么做吗 ?