Guest User

Untitled

a guest
Jul 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. class Posts::PdfsController < ApplicationController
  2.  
  3. def show
  4. @post = Post.find(params[:id])
  5.  
  6. resond_to do |format|
  7. format.html do
  8. redirect_to post_pdf_path(@post, format: :pdf)
  9. end
  10. format.pdf do
  11. pdf = render_to_string(
  12. pdf: "#{@post.uuid}",
  13. encoding: 'UTF-8',
  14. layout: 'pdf',
  15. template: 'posts/pdfs/show.pdf.erb',
  16. page_size: 'A4'
  17. )
  18. send_data(pdf, filename: "#{@post.uuid}.pdf")
  19. end
  20. end
  21.  
  22. end
  23.  
  24. end
Add Comment
Please, Sign In to add comment