Last active
December 14, 2015 01:49
-
-
Save sideshowcoder/5009089 to your computer and use it in GitHub Desktop.
Render from model in rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeModel < ActiveRecord::Base | |
... | |
def render_pdf | |
ac = ApplicationController.new | |
ac.instance_variable_set("@some_variable_needed_in_template", some_variable) | |
pdf = ac.render_to_string(pdf: "the_pdf_filename", template: 'pdf_templates/filename') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment