Posted: December 29th, 2009 | Author: gozali | Filed under: Programming, Rails, Ruby, Work | Tags: pdf, prawn, prawnto, ruby, ruby on rails | 1 Comment »
I was getting stuck how to generate dynamic file name for prawn generated pdf file, because there’s lack of example and document here http://cracklabs.com/prawnto/demos
What is Prawnto? Prawnto is is a rails plugin leveraging the new prawn library to produce compiled pdf views, as for me i’m using it for custom reporting tools.
OK, let’s getting back to the problem, what should you do is place prawnto definition in your method rather than in controller’s callbacks :
# /app/controllers/transactions_controller.rb
1
2
3
4
5
6
7
8
9
| def show
prawnto :prawn => { :page_size => 'A4',
:left_margin => 40,
:right_margin => 30,
:top_margin => 40,
:bottom_margin => 30},
:filename => "invoice_#{@transaction.id}_customer_#{@transaction.customer_id}.pdf"
render :layout => false
end |
# /app/views/transactions/show.pdf.prawn
1
| <%= link_to "Generate PDF", transaction_url(transaction.id, :format => 'pdf') %> |
Hope this is useful, cheers
Posted: December 10th, 2009 | Author: gozali | Filed under: Programming, Ruby | Tags: jakarta.rb, meetup, ruby, ruby on rails | No Comments »
The last meeting Jakarta.rb in 2009 is going to be:
When:
Saturday, December 12nd at 10 AM
Where:
detikcom office
Gedung Aldevco Octagon Lt. 2,
Jl. Warung Jati Barat Raya No. 75
Jakarta Selatan
Google Map Link
Call me: 0818-0308-1790 if you get lost.
The building is across the street from the Pizza Hut Warung Buncit and Buncit Indah Busway Shelter. The entrance to the building is in back by the parking lot.
Topics:
We will have 2 presentations no longer then 30 minutes each:
BDD with Cucumber – by Kunto Aji (http://www.railsmine.net)
W2tags Live – by Widi Harsojo of Koprol (http://wharsojo.wordpress.com)
We are opening open submission, we welcome all your resources (codes, videos, documentations, slides, presentation) for our next meetup
Posted: July 25th, 2009 | Author: gozali | Filed under: Programming, Technology, Work | Tags: capistrano, deployment, ruby, ruby on rails | No Comments »
Sesuai dengan request dari Mas Agung Sachli di id-ruby group, saya dengan terpaksa insyaAllah akan membawakan materi Ruby on Rails Deployment untuk Jakarta.rb Edisi Juli, yang akan saya khususkan menggunakan Phusion Passenger yang saat ini sepertinya menjadi lebih populer dibandingkan Mongrel atau Thin.
Berikut merupakan langkah installasi Phusion Passenger (mod_rails) melalui Rubygems, dengan prasyarat Apache Webserver sudah terinstall terlebih dahulu di mesin anda.
- Install passenger gem
sudo gem install passenger
- Install passenger sebagai Apache module
passenger-install-apache2-module
- Tambahkan passenger_module di Apache config agar di-load oleh Apache
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.3/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.3
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Kita akan mendapatkan tiga baris kode diatas setelah installasi passenger gem selesai. Untuk linux memiliki path yang berbeda. Kode di atas merupakan konfigurasi untuk OSX, namun biasanya terletak pada direktori /usr/local
Read the rest of this entry »