Strange problem with Gruff not always displaying graph



I am having a strange problem with Gruff not always displaying the graph
on the page. On some pages, the graph is displayed fine. On others,
however, I just get the number relating to the id of the requested item

  • in my case, report.

Does anyone know how to solve this problem?

I have the following in my controller:

def create_graph

 g =
 g.title = "Reports"

 g.theme = {
   :colors => ['#CC0000', '#00CC00', '#cc6633', '#cc9966',

:marker_color => ‘black’,
:background_colors => [’#FAFAFA’, ‘#FAFAFA’]

  report_number = []
  labels = []

 @report = User.find(session[:user]).reports.find(params[:id])
 @records = @report.report_items.find(:all, :conditions => [

“report_context = ‘Required’” ] )

  for report_items in @records
    report_number << report_item.amount.to_i
labels <<
  end"Reports", report_number)
  g.labels = labels

:disposition => 'inline',
:type => 'image/png',
:filename => "report_img.png")


Then, in the view, I have the following:

<%= image_tag url_for(:controller => ‘reports’, :action =>
‘create_graph’, :id => @report) %>

Why would the image appear for some of the report pages and not the

Any help on this would be great.



Problem sorted, thanks