Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render file Rails3

I'm trying to render a png file in a controller in Rails3. I'm using:

render :file=>'public/images/filename.png'

However, the output seems not to be a PNG file (its contents start with "PNG" -checked it with curl- but it's not a valid file). I cannot find documentation on render :file in Rails3. Has the syntax changed for this? Even if it's a MIME type issue, I think I should be able to obtain the file with curl.

I'm using this technique to show a default image when using Fleximage's images if available. Fleximage's images work correctly, but this simple operation does not.

like image 310
Jose Avatar asked Apr 22 '26 00:04

Jose


1 Answers

use:

send_file path_to_file
like image 200
Andrea Pavoni Avatar answered Apr 24 '26 09:04

Andrea Pavoni