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 <img src="http://myhost:3000/stats/make_graph" /> 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 Chappuis wrote:> 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 > > <img src="http://myhost:3000/stats/make_graph" /> > > 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... -- Alex
> > <img src="http://myhost:3000/stats/make_graph" /> > > > > 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!
Just use <img src="/stats/make_graph"/>. Image_tag is too wordy here. On 1/9/06, Mathieu Chappuis <mathieu.chappuis.lists@gmail.com> wrote:> > 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 > > <img src="http://myhost:3000/stats/make_graph" /> > > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Blog >>> http://spaces.msn.com/members/skyincookoo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060109/37d9c10a/attachment.html
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. Alex Young wrote: Mathieu Chappuis wrote: 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 "http://myhost:3000/stats/make_graph" /> 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... _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 19.1.2006, at 0.16, Dylan Markow 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 <img src=...> 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> > Alex Young wrote: >> Mathieu Chappuis wrote: >>> 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 >>> >>> <img src="http://myhost:3000/stats/make_graph" /> >>> >>> 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... >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- Jarkko Laine http://jlaine.net http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2363 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060119/4a0da535/smime.bin
Dylan Markow 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 <img src=...> tag to get it to work.In that case: <%= tag ''img'', :src => url_for(...), :alt => ''foo'' %> -- Alex