Rendering dynamic Gruff image (send_data)


#1

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


#2

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…


#3

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!


#4

Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


#5

Just use . Image_tag is too wordy here.


#6

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


#7

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’ %>