Forum: Ruby on Rails Dynamic images

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F7975423060c2c9e4395dca3ae870771?d=identicon&s=25 De Railed (kitesurfer)
on 2005-12-04 22:05
Hi,

   I have a controller that uses gruff to create a chart. I would like
to be able to return this image back to the view without having to dump
the image to disk first. Does anyone have sample code for the controller
and view to handle such a problem ?

Thank you all !!
280b41a88665fd8c699e83a9a25ef949?d=identicon&s=25 steve (Guest)
on 2005-12-04 22:51
(Received via mailing list)
On Dec 4, 2005, at 1:05 PM, KiteSurfer KiteSurfer wrote:

> Does anyone have sample code for the controller
> and view to handle such a problem ?

Create a specific action to generate the image and send it with
[send_data][1].

--Steve

[1]: http://api.rubyonrails.com/classes/ActionController/
Streaming.html#M000041
F7975423060c2c9e4395dca3ae870771?d=identicon&s=25 De Railed (kitesurfer)
on 2005-12-05 00:27
Thanks Steve !! That helps but...

send_data will forward me to a new page. I want to be able to display
the chart within the existing page ?

I guess I am not really sure how to formulate the send_data from within
the page ??
280b41a88665fd8c699e83a9a25ef949?d=identicon&s=25 steve (Guest)
on 2005-12-05 00:53
(Received via mailing list)
On Dec 4, 2005, at 3:27 PM, KiteSurfer KiteSurfer wrote:

> I guess I am not really sure how to formulate the send_data from
> within
> the page ??

Create a separate dedicated action, just for the image, then within
whatever page you just link to that like a regular image.

HTH,
Steve
F7975423060c2c9e4395dca3ae870771?d=identicon&s=25 De Railed (kitesurfer)
on 2005-12-05 01:23
Got it !! Thanks Steve you tough me something cool today...

Now do you know how to accomplish the same thing using an ajax call ?
280b41a88665fd8c699e83a9a25ef949?d=identicon&s=25 steve (Guest)
on 2005-12-05 05:12
(Received via mailing list)
On Dec 4, 2005, at 4:23 PM, KiteSurfer KiteSurfer wrote:

> Now do you know how to accomplish the same thing using an ajax call ?

Someone else will have to chime in to help you with that.  :)  Good
luck.

--Steve
8c7a98649cdbbdf39eeed17ca9bdbbd3?d=identicon&s=25 josh.charles (Guest)
on 2005-12-05 05:16
(Received via mailing list)
I'm not sure if it's possible, as ajax only deals with text based
data.  However, you might be able to send an <img> tag that loads a
dynamic image...
Cee38055ae36590c654c04c2d5cc2778?d=identicon&s=25 sky.yin (Guest)
on 2005-12-05 06:08
(Received via mailing list)
hmmm, a noob ruby question. After I gem install gruff,  I opened the irb
to
try require 'rubygems' and require 'gruff', and then I got two false.
Why?
I'm using ruby 1.8.3 on WinXP. I also put the sample code from gruff's
home
page into a controller. It seems rails still didn't know the name of
'gruff'.

Thanks,

Sky
F7975423060c2c9e4395dca3ae870771?d=identicon&s=25 De Railed (kitesurfer)
on 2005-12-05 07:21
Steve : No problem. Thanks again for the help !!
I think I need to dig in google map apis to try to figure this one out.
It
must be achievable using javascript.

Sky: I have successfully installed Gruff on both linux and windows. For
both of these you need to have ImageMagick or GraphMagick installed. You
also need Rmagick. Somehow it was not clear from the docs that gruff had
these dependencies when I started to look at it...

Hope this helps...
This topic is locked and can not be replied to.