开发者

Render file Rails3

开发者 https://www.devze.com 2023-01-11 04:07 出处:网络
I\'m trying to render a png file in a controller in Rails3. I\'m using: render :file=>\'public/images/filename.png\'

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. Fl开发者_JAVA技巧eximage's images work correctly, but this simple operation does not.


use:

send_file path_to_file
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号