Rendering dynamic Gruff image (send_data)

Dears,

Got a controller witch do a send_data for displaying a chart.

like :

send_data(g.to_blob, :filename => “any.png”, :type => ‘image/png’,
:disposition=> ‘inline’)

I actually do a

Is there any way more clean to do that ? At minima don’t hardcode the
beginning of the url (host:port)

I’ve tried a bit ‘render’ w/o success.

Thanks

Mathieu C. wrote:

Is there any way more clean to do that ? At minima don’t hardcode the
beginning of the url (host:port)
<%= image_tag(url_for(:action => ‘make_graph’, :controller => ‘stats’))
%>

Should do it…

Is there any way more clean to do that ? At minima don’t hardcode the
beginning of the url (host:port)
<%= image_tag(url_for(:action => ‘make_graph’, :controller => ‘stats’)) %>

Should do it…

Thanks very much!


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Just use . Image_tag is too wordy here.

On 19.1.2006, at 0.16, Dylan M. wrote:

When I try something like this, the resulting HTML links to “/stats/
make_graph.png” instead of “/stats/make_graph”. Because of this,
only the “alt” title shows up with no graph. I have to manually
create an tag to get it to work.

image_tag is a bit “too” wise in this case, because it adds the .png
to the image name by default if there’s no suffix.

You can fix it by creating a route like this:
map.connect ‘stats/make_graph.png’, :controller => ‘stats’, :action
=> ‘make_graph’

and putting it in your config/routes.rb. Then the image url even
looks like an image filename.

//jarkko

Dylan M. wrote:

When I try something like this, the resulting HTML links to
“/stats/make_graph.png” instead of “/stats/make_graph”. Because of this,
only the “alt” title shows up with no graph. I have to manually create
an tag to get it to work.
In that case:

<%= tag ‘img’, :src => url_for(…), :alt => ‘foo’ %>