Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Posts::PdfsController < ApplicationController
- def show
- @post = Post.find(params[:id])
- resond_to do |format|
- format.html do
- redirect_to post_pdf_path(@post, format: :pdf)
- end
- format.pdf do
- pdf = render_to_string(
- pdf: "#{@post.uuid}",
- encoding: 'UTF-8',
- layout: 'pdf',
- template: 'posts/pdfs/show.pdf.erb',
- page_size: 'A4'
- )
- send_data(pdf, filename: "#{@post.uuid}.pdf")
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment