url, hash, flatten, etc.

Hi,

I have a form which generates statistics:

form.rhtml --> /my_big_app/stats/generate --> view_results.rhtml

My method 'generate' generates an array of statistics @results = [hash_1,hash_2,etc.] and I want to display graphics with gruff in my view_results.rhtml page:

@results.each do |result| generate_graphic(result) end

My helper generate_graphic simply renders <img src='/my_big/app/graph_controller/generate_image/'> (I can't use image_tag since it automatically adds now a .png).

So how can I easily pass my hashes to my graph_controller? I want to have a params[:stats] = my_hash for the generate_image method but I need to flatten the hash which is ugly with a whole bunch of data.

Do you have any idea?

Pierre-Alexandre Meyer wrote:

Hi,

I have a form which generates statistics:

form.rhtml --> /my_big_app/stats/generate --> view_results.rhtml

My method 'generate' generates an array of statistics @results = [hash_1,hash_2,etc.] and I want to display graphics with gruff in my view_results.rhtml page:

@results.each do |result| generate_graphic(result) end

My helper generate_graphic simply renders <img src='/my_big/app/graph_controller/generate_image/'> (I can't use image_tag since it automatically adds now a .png).

So how can I easily pass my hashes to my graph_controller? I want to have a params[:stats] = my_hash for the generate_image method but I need to flatten the hash which is ugly with a whole bunch of data.

Do you have any idea?

Store it directly in the session object or store it somewhere else and point to it with the session id?

Actually, it's what I'm currently doing but I'm not persuaded it's the proper.superlative (propest? sounds weird) way to do this, since it's a lot of information which is periodically updated.