Hi you all,
I've used the library SVG::Graph to generate SVG images.
I have this code in the controller:
respond_to do |format|
format.html
format.xml { render :xml => @graphic.to_svg}
end
When html, I display a jpg graph.
When XML, I make the graphic with SVG::Graph and the xml appears.
To see this SVG graph, I can store the resulting XML file from my
browser, renaming it with the .svg extension, and clicking on the
resulting file (I have the adobe plugin to see SVG images).
This is tedious, and this is why I've added the following in the
controller:
format.svg { render :xml => @graphic.to_svg}
And the following in environment.rb:
Mime::Type.register "image/svg+xml", :svg
But this does not display the image directly; it stills renders an XML
file.
What should I do? Thanks.
Hi Peter,
no, it does not work.
I've added: headers["content-type"] = "image/svg+xml"
and what happens is that when accesing, I received a message if I want
to open or save the file "graphic.svg" (it is not displayed directly in
the browser). It does not matter what I do, but the file is never open
or saved, cause it does not exist ( because it is not a file stored in
the server, i'm afraid).