This is easy to do with shrimp , Gemfile => gem 'prawn', bundle
will say that you have a Client :
customers_controller.rb
def show
@customer = Customer.find(params[:id])
respond_to do |format|
format.html
format.pdf do
pdf = CustomerPdf.new(@customer)
send_data pdf.render, filename: "customer_#{id}.pdf",
type: "application/pdf",
disposition: "inline"
end
end
end
pdfs apps customer_pdf.rb
class CustomerPdf< Prawn::Document
def initialize(customer)
super()
@customer = customer
text "Id\##{@customer.id}"
text "Name\##{@customer.name}"
end
end
show.html.erb
<div class="pdf_link">
<%= link_to "E-version", customer_path(@customer, :format => "pdf") %>
</div>
EDIT:
pdf config/initializers/mime_types.rb
Mime::Type.register "application/pdf", :pdf