# Scruffy question

**URL:** <https://www.ruby-forum.com/t/scruffy-question/119251>\
**Category:** Ruby\
**Created:** [November 5, 2007, 12:50pm UTC](https://www.ruby-forum.com/t/scruffy-question/119251 "2007-11-05T12:50:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 5, 2007, 12:50pm UTC](https://www.ruby-forum.com/t/scruffy-question/119251/1 "2007-11-05T12:50:38Z")

</div>

Hi

installed scruffy…and put the code below in my controller.

def show\_img  
graph = Scruffy::Graph.new  
graph.title = “Comparative Agent Performance”  
graph.value\_formatter =  
Scruffy::Formatters::Percentage.new(:precision =\> 0)

```
graph.add :stacked do |stacked|
  stacked.add :bar, 'remco', [30, 60, 49, 29, 100, 120]
  stacked.add :bar, 'peter', [120, 240, 0, 100, 140, 20]
  stacked.add :bar, 'femmie', [10, 10, 90, 20, 40, 10]
end

graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']

send_data(graph.render(:width => 800, :as => 'PNG'), :type =>

```

‘image/png’, :disposition=\> ‘inline’)  
end

In the view a placed…

![]()

But with no succes…

In the generated HTML i get

![](https://www.ruby-forum.com/users/show_img)

What i am doing wrong???

remco

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [November 7, 2007, 9:19am UTC](https://www.ruby-forum.com/t/scruffy-question/119251/2 "2007-11-07T09:19:17Z")

</div>

I’m not familiar with what you are doing, but I’m pretty sure you need  
to save the file in a public directory. Save that path as a variable  
which you can use in the view.

And on a side note, url\_for(:action) just builds the relative path for  
the page show\_img creates. url\_for is for building relative links to  
other controllers and actions. These paths are not real paths in your  
public directory, they are virtual paths rails builds for you when you  
request them.

The rails list would be your best bet for more in depth help.

Jake

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [December 13, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/scruffy-question/119251/3 "2007-12-13T18:15:15Z")

</div>

Hi,

I have tested with :  
send\_data(graph.render(:width =\> 800, :as =\> ‘PNG’, :to =\>  
“#{RAILS\_ROOT}” + “/public/images/test.png”), :type =\>‘image/png’,  
:disposition =\> ‘inline’)

instead of :  
send\_data(graph.render(:width =\> 800, :as =\> ‘PNG’), :type =\>  
‘image/png’, :disposition=\> ‘inline’)

But i have the same problem :  
app/controllers/supports\_controller.rb:88: syntax error, unexpected  
tSTRING\_BEG, expecting $end  
end’,gfd :disposition=\> ‘inline’)  
^

I can’t understand !!!

Who can help me to use Scruffy with RoR ?

Got

---

<div class="post-metadata">

**Author:** ![remco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@remco](https://www.ruby-forum.com/u/remco)\
**Post date:** [December 27, 2007, 12:49pm UTC](https://www.ruby-forum.com/t/scruffy-question/119251/4 "2007-12-27T12:49:10Z")

</div>

Hi,

Finally, I’m trying to test Scruffy in my ‘application\_helper.rb’ :

def render\_scruffy\_graph  
graph = Scruffy::Graph.new  
graph.title = “Comparative Agent Performance”  
graph.value\_formatter =  
Scruffy::Formatters::Percentage.new(:precision =\> 0)  
graph.add :stacked do |stacked|  
stacked.add :bar, ‘remco’, [30, 60, 49, 29, 100, 120]  
stacked.add :bar, ‘peter’, [120, 240, 0, 100, 140, 20]  
stacked.add :bar, ‘femmie’, [10, 10, 90, 20, 40, 10]  
end  
graph.point\_markers = [‘Jan’, ‘Feb’, ‘Mar’, ‘Apr’, ‘May’, ‘Jun’]  
graph.render(:width =\> 800, :as =\> ‘PNG’)  
end

with :  
\<%= render\_scruffy\_graph %\> #in my ‘show.rhtml’ file

But the image is returned as blob/string.

So I’ve got something like that :

> ÏŸ?ï¿½Õ«Wï¿½kï¿½.,[ï¿½~ï¿½ï¿½gï¿½ï¿½GDï¿½ï¿½ï¿½VkDï¿½AdM`` Æï¿½~ï¿½ï¿½Bï¿½Vï¿½M{ï¿½ï¿½Mï¿½ï¿½ï¿½[Ø¿ï¿½ï¿½ï¿½&ï¿½ï¿½jï¿½ ï¿½’OFÅŠï¿½nï¿½ï¿½uï¿½ï¿½5ï¿½ï¿½ï¿½ï¿½RÅŠÃe×¡Rï¿½ï¿½5k4Tï¿½ï¿½ï¿½Sï¿½xN!ï¿½ï¿½á¨”ï¿½(=ï¿½ï¿½ï¿½ï¿½ï¿½W\_aÊ”?ï¿½ï¿½ï¿½Â…cï¿½ï¿½}(Vï¿½ï¿½Å¶ï¿½ cÇŽUï¿½ï¿½Dï¿½q9ï¿½Úµkï¿½Ü¹ï¿½8p@ï¿½ï¿½ï¿½(]:Û·oCï¿½Þ½ï¿½.:I`Õªï¿½Ø²e3Ê•+ï¿½tQ1hï¿½@ï¿½ï¿½aï¿½ï¿½T\*4Pï¿½9gï¿½ï¿½ï¿½ï¿½0aFï¿½ï¿½t8ï¿½|ï¿½ï¿½Veï¿½pï¿½ï¿½ï¿½ï¿½GDï¿½ï€Ó©Rï¿½ ï¿½ï¿½ï¿½OOOï¿½I]"ï¿½/\_ï¿½Uï¿½Vï¿½ï¿½ï¿½ï¿½xï¿½ï¿½9ï¿½ï¿½ï¿½Pï¿½\9ï¿½ï¿½ï¿½ï¿½7yï¿½ï¿½1ï¿½mÞ¼\>ï¿½ï¿½Û ,ï¿½ï¿½ï¿½nï¿½EÜ¸qÅ‹aï¿½ÌŸï¿½ï¿½Cï¿½ï¿½Ü¹seÊ”ï¿½(ï¿½ï¿½ï¿½xVï¿½Gï¿½…Dï¿½-ï¿½ï¿½7ß dï¿½ï¿½ï¿½ï¿½ï¿½hTï¿½P\>T:,ï¿½ï¿½[ï¿½nï¿½ ï¿½×¯ï¿½ï¿½Ñ£rHHH@\ï¿½ï¿½E$ï¿½\ï¿½ r_ï¿½ï¿½ï¿½8sï¿½ï¿½ï¿½Jï¿½nÝºï¿½=zï¿½ï¿½ï¿½ï¿½6ï¿½)Sï¿½46oÞ‚%ï¿½.ï¿½nÞ¼ï¿½ï¿½+rLHï¿½ï¿½e ï¿½Zï¿½Â–-ï¿½ï¿½ï¿½=Bï¿½ï¿½epï¿½ï¿½5,Xï¿½Ð¶m;ï¿½Ü¹Sï¿½b_Jï¿½Hjï¿½ï¿½aLï¿½cÇŽÅ?ï¿½ï¿½tXï¿½ï¿½ï¿½ï¿½Qpssï¿½ï¿½)Sï¿½oï¿½Qï¿½HDDP Hz!.Î°|ï¿½ï¿½(Sï¿½#44-[ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½sï¿½ï¿½ t{ï¿½5ï¿½ï¿½Ó ï¿½Rï¿½

How can I show my picture ?  
Thx  
Got
