Here’s a challenge to all you good rails programmers: how does one
display SVG images in Rails ? Now I realize many of you ignore SVG
since it “isn’t supported everywhere” but that is rapidly changing (it
is supported in Firefox since 1.5, it’s now in the Safari overnight
builds, and in IE under the SVG plugin - which is usually shipped but
not activated with the Adobe plugins.
Since SVG can be displayed in ordinary HTML (using <embed type=image/
svg+xml in Firefox), I can only think of 2 reasons that it is not
recognized under Rails:
- maybe Webrick or Mongrel doesn’t recognize it ?
- somewhere Rails doesn’t recognize the mime type - I’ve tried
changing mime in 2 locations:
a) in the environment.rb file under myproject/config
adding Mime::Type.register “image/svg+xml” (also tried “application/
b) in httputils.rb under /usr/lib/ruby/1.8/webrick/
adding “svg” => “image/svg+xml”
But no matter what I try the browser recognizes it is a svg file but
wants to just save it (indicative of a mime problem).
Can anyone solve this problem ?