Topic: Open Flash chart in a partial template - how to?

I have been trying to get Open Flash chart to work in my partial template and everything i try just does not work.

Can somebody be kind enough to show a newbie where they are going wrong!

One of the problems is, in my controller I am not using the index action,  i am using a separate action called by ajax.

So when my partial loads, the graph is activating the wrong action in the controller so I get this error...

ActiveRecord::RecordNotFound (Couldn't find Event with ID=graph_code):

controller code...

  def graphresults
    @graph = open_flash_chart_object(600,100,"/events/graph_code")
    render :partial => "graphresults" , :layout => false
  end

  def graph_code
     title = Title.new("MY TITLE")
    bar = BarGlass.new
    bar.set_values([1,2,3,4,5,6,7,8,9])
    chart = OpenFlashChart.new
    chart.set_title(title)
    chart.add_element(bar)
    render :text => chart.to_s

  end

and in my partial view....

<script type="text/javascript" src="/javascripts/swfobject.js"></script>
<%= @graph %>

Any help would kindly be appreciated
Thanks

Re: Open Flash chart in a partial template - how to?

You could try to change the 'call' to the action and add an ID, even if no ID is required in the action. But the routing to the action will probably need id.

  def graphresults
    @graph = open_flash_chart_object(600,100,"/events/ID/graph_code")
    render :partial => "graphresults" , :layout => false
  end

cheers, Rainer

Re: Open Flash chart in a partial template - how to?

Thanks Rainer

I actually decide to create a separate controller with its own index action.

So it seams to be functioning well with my tests.

Regards