I would like to write form data into a file, and I would like
to know if there's a way for me to use an ERB template
directly to output the file to disk?
I was going to use a series of puts("Full name: @order.full_name")
statements, but thought, there MUST be a better way!
any help or advice on what would be the most efficient way to
tackle this in RoR would be much appreciated.
I would like to write form data into a file, and I would like
to know if there's a way for me to use an ERB template
directly to output the file to disk?
I was going to use a series of puts("Full name: @order.full_name")
statements, but thought, there MUST be a better way!
any help or advice on what would be the most efficient way to
tackle this in RoR would be much appreciated.
As I understand your question you have an ERB template and instead of rendering it to the screen you want to render the template to a file on the disk. One way of doing this is to use the render_to_string function from Rails. Check out:
Thank you very much for your help, this seems to be exactly what I
was
looking for! I just have one question about usage.
The documentation says:
"Renders according to the same rules as
render,
but returns the result in a string instead of
sending
it as the response body to the browser."
Does this mean it takes the ENTIRE ERB template (multiline) and
puts it into one long string? or does it convert each line of the
string into an item in a COLLECTION?
puts(template) # will this put all of it in?
or do I need to loop over and build the file one string at a time
Thank you very much for your help, this seems to be exactly what I
was
looking for! I just have one question about usage.
The documentation says:
"Renders according to the same rules as
render,
but returns the result in a string instead of
sending
it as the response body to the browser."
Does this mean it takes the ENTIRE ERB template (multiline) and
puts it into one long string? or does it convert each line of the
string into an item in a COLLECTION?