Static variables

Hi
In controller I have
def role_wise_summary_graph_render
@graph1 = open_flash_chart_object(300,200,
“#{summary_graph_path(:role_name => ‘Role1’)}”, true)
@graph2 = open_flash_chart_object(300,200,
“#{summary_graph_path(:role_name => ‘Role2’)}”, true)
respond_to do |format|

    end

end

###summary_graph_path => :action => draw_role_level_summary_graph
def draw_role_level_summary_graph

@role1_array,@role2_array,@open_requests =
MyRequest.get_role_wise_summary_graph_data

if params[:role_name] == 'Role1'
  role_data_array = @role1_array
elsif params[:role_name] == 'Role2'
  role_data_array = @role2_array
end
 graph =

role_level_graph(params[:role_name],role_data_array,@open_requests)
render :text => graph.render
end

Here in above role_level_graph is a library function finally

responsible for drawing graph The above code is working
My question is in the above how can I make the varibales
@role1_array,@role2_array,@open_requests static so that only once
MyRequest.get_role_wise_summary_graph_data get called Because I need it
only once But happens now is all the two times this def gets called How
can I avoid this to call this only once and get the details

Thanks in advance
SSijo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs