ruby on rails - Is it possible to convert a string into a partial? -
i have string stored in database used custom layout.
i parse custom layout inside of app layout, using :
render_to_string(partial: custom_template, layout: "pdf_template", locals: locals)
where custom_template
string db. however, when try :
nomethoderror: undefined method `to_sym' nil:nilclass
is possible i'm doing? if so, can complete this?
i've noted can try things :
render_to_string(text: template, locals: locals, template: "pdf_template")
and
render_to_string(inline: template, locals: locals, template: "pdf_template")
but doing so, can't find template , returns :
actionview::missingtemplate: missing template layouts/pdf_template {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:pdf], :locale=>[:en, :en]}. searched in: * "/users/elephanttrip/sites/shasta/app/views"
which strange because worked fine in current location , definition.
if want store views in database, should use rendering engine rather in rails default. check liquid gem (http://railscasts.com/episodes/118-liquid, http://rubygems.org/gems/liquid).
for example, use gem render emails our maillists (their templates stored in db).
Comments
Post a Comment