Hi, for those with experience of Gruff module: suppose I want to send image from server straight to the browser (as example on gruff web site): send_data(g.to_blob, :disposition => ''inline'', :type => ''image/png'', :filename => "gruff.png") the server seems sending this binary data ok, but I am having trouble to display it properly: I have tried <%= link_to_image "gruff.png"%> or <%= image_tag "gruff.png" %>. Neither works. The browser gives a bunch of binary encoding. Any idea? Thanks in advance. Oliver --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I just write the file to the disk and serve up the image. i.e: g.write(filename), and then use the image tag helper in the view like you have done. Shane http://shanesbrain.net On 4/9/07, Oliver <fwang2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, > > for those with experience of Gruff module: suppose I want to send > image from server straight to the browser (as example on gruff web > site): > > send_data(g.to_blob, > :disposition => ''inline'', > :type => ''image/png'', > :filename => "gruff.png") > > > the server seems sending this binary data ok, but I am having trouble > to display it properly: > > I have tried > > <%= link_to_image "gruff.png"%> or <%= image_tag "gruff.png" %>. > Neither works. The browser gives a bunch of binary encoding. > > Any idea? > > Thanks in advance. > > Oliver > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You seem to have everything right except the image_tag: Try: image_tag(url_for(:controller => ''my_gruff_controller'', :action => ''my_gruff_action'')) What you''re trying to achieve is: http://mydomain.com/my_gruff_controller/my_gruff_action Does this make sense? Oliver-23 wrote:> > > Hi, > > for those with experience of Gruff module: suppose I want to send > image from server straight to the browser (as example on gruff web > site): > > send_data(g.to_blob, > :disposition => ''inline'', > :type => ''image/png'', > :filename => "gruff.png") > > > the server seems sending this binary data ok, but I am having trouble > to display it properly: > > I have tried > > <%= link_to_image "gruff.png"%> or <%= image_tag "gruff.png" %>. > Neither works. The browser gives a bunch of binary encoding. > > Any idea? > > Thanks in advance. > > Oliver > > > > > >-- View this message in context: http://www.nabble.com/gruff-send_data-tf3548362.html#a9907760 Sent from the RubyOnRails Users mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the reply. That is certainly one way to go about it. I was able to write a file and read it properly. Some issues with this approach: I have put this image into a a periodic update section. Write it then read it make the refresh rather obvious. I was hoping send_data will make it visually a little better, but then I guess this might not be the "rails" way of doing this kind of update ... So far, I think I didn''t really find a GOOD way to give you live update charting with gruff ... Oliver On Apr 9, 3:08 pm, "Shane Vitarana" <sha...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I just write the file to the disk and serve up the image. i.e: > g.write(filename), > and then use the image tag helper in the view like you have done. > > Shanehttp://shanesbrain.net > > On 4/9/07, Oliver <fwa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > for those with experience of Gruff module: suppose I want to send > > image from server straight to the browser (as example on gruff web > > site): > > > send_data(g.to_blob, > > :disposition => ''inline'', > > :type => ''image/png'', > > :filename => "gruff.png") > > > the server seems sending this binary data ok, but I am having trouble > > to display it properly: > > > I have tried > > > <%= link_to_image "gruff.png"%> or <%= image_tag "gruff.png" %>. > > Neither works. The browser gives a bunch of binary encoding. > > > Any idea? > > > Thanks in advance. > > > Oliver--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks - by coincidence, I also stumble onto this way of calling ... I believe this will work under normal circumstances ... what if I am calling it this way to update only this <div> section? ... I am not so sure anymore <%= periodically_call_remote( :update => "show_graph", :frequency => 5, :url => { :action => :gruff_report}) %> <div id="show_graph"> </div> Oliver On Apr 9, 3:42 pm, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You seem to have everything right except the image_tag: > > Try: > > image_tag(url_for(:controller => ''my_gruff_controller'', :action => > ''my_gruff_action'')) > > What you''re trying to achieve is: > > http://mydomain.com/my_gruff_controller/my_gruff_action > > Does this make sense? > > > > Oliver-23 wrote: > > > Hi, > > > for those with experience of Gruff module: suppose I want to send > > image from server straight to the browser (as example on gruff web > > site): > > > send_data(g.to_blob, > > :disposition => ''inline'', > > :type => ''image/png'', > > :filename => "gruff.png") > > > the server seems sending this binary data ok, but I am having trouble > > to display it properly: > > > I have tried > > > <%= link_to_image "gruff.png"%> or <%= image_tag "gruff.png" %>. > > Neither works. The browser gives a bunch of binary encoding. > > > Any idea? > > > Thanks in advance. > > > Oliver > > -- > View this message in context:http://www.nabble.com/gruff-send_data-tf3548362.html#a9907760 > Sent from the RubyOnRails Users mailing list archive at Nabble.com.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 4/9/07, Oliver <fwang2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > for those with experience of Gruff module: suppose I want to send > image from server straight to the browser (as example on gruff web > site): > > send_data(g.to_blob, > :disposition => ''inline'', > :type => ''image/png'', > :filename => "gruff.png") > > > the server seems sending this binary data ok, but I am having trouble > to display it properly: > > I have tried > > <%= link_to_image "gruff.png"%> or <%= image_tag "gruff.png" %>. > Neither works. The browser gives a bunch of binary encoding. > > Any idea? > > Thanks in advance. > > Oliver > >I used respond_to to do this: in the controller something like: respond_to do |format| format.html format.png do send_data(g.to_blob, :disposition => ''inline'', :type => ''image/png'', :filename => "gruff.png") end then the route needs to have :controller/:action/:id.:format then controller/action/id will give you the html (probably a page with an img tag to the actual chart), and controller/action/id.png will return the actual image. Hope that helps, Andy Delcambre --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Presuming the ''gruff_report'' action renders the correct html to fill the ''show_graph'' element, you should be fine. Bear in mind that gruff graphs can be a chunky download, so refreshing them every 5 seconds might be hard on the server. Oliver-23 wrote:> > > Thanks - by coincidence, I also stumble onto this way of calling ... > I believe this will work under normal circumstances ... what if I am > calling it this way to update only this <div> section? ... I am not > so sure anymore > > <%= periodically_call_remote( > :update => "show_graph", > :frequency => 5, > :url => { :action => :gruff_report}) > %> > > <div id="show_graph"> </div> > > Oliver > > On Apr 9, 3:42 pm, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> You seem to have everything right except the image_tag: >> >> Try: >> >> image_tag(url_for(:controller => ''my_gruff_controller'', :action => >> ''my_gruff_action'')) >> >> What you''re trying to achieve is: >> >> http://mydomain.com/my_gruff_controller/my_gruff_action >> >> Does this make sense? >> >> >> >> Oliver-23 wrote: >> >> > Hi, >> >> > for those with experience of Gruff module: suppose I want to send >> > image from server straight to the browser (as example on gruff web >> > site): >> >> > send_data(g.to_blob, >> > :disposition => ''inline'', >> > :type => ''image/png'', >> > :filename => "gruff.png") >> >> > the server seems sending this binary data ok, but I am having trouble >> > to display it properly: >> >> > I have tried >> >> > <%= link_to_image "gruff.png"%> or <%= image_tag "gruff.png" %>. >> > Neither works. The browser gives a bunch of binary encoding. >> >> > Any idea? >> >> > Thanks in advance. >> >> > Oliver >> >> -- >> View this message in >> context:http://www.nabble.com/gruff-send_data-tf3548362.html#a9907760 >> Sent from the RubyOnRails Users mailing list archive at Nabble.com. > > > > > >-- View this message in context: http://www.nabble.com/gruff-send_data-tf3548362.html#a9912883 Sent from the RubyOnRails Users mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---