How do you render file as a plain/text in rails (without rendering any HTML)?
I've tried:
render file: "path/to/file", layout: false
and
render file: "path/to/file", content_type: 'text/plain'
also both
render file: "path/to/file", layout: false, content_type: 'text/plain'
But there still some html on the response.
I'm using rails 3.2.14 and ruby 1.9.3
Thanks in advance.
EDIT 1:
Silly me, this actually works:
render file: "path/to/file", layout: false, content_type: 'text/plain'
I was inspecting the element using google chrome, so there's an html tag appears. But when I see the source, there's no HTML tag.
The file I was trying to render is a custom made file without extension, it is a tab separated value I use as a parameter in d3.tsv() (D3.js)
Thank you all for your efforts. :D
EDIT 2:
In Edit 1, I checked the response and it's true that it doesn't come with any html tag. But using it as parameter in d3.tsv() (D3.js) doesn't work apparently. Glad I tried the answer from JetAbe and it works! So I accepted JetAbe's answer.
layout: false
will apply no layout meaning whats in that file is what you get. – Tolmach