How can I generate images in real-time using Ruby on Rails and Gruff? -


i draw bar graphs in app using gruff. in 1 view, 'compare', want show 1 graph every 'step' 'project' has. imagine this:

image_tag graph_step_path(step) 

i've created 'graph' action in step controller , included route. i'm kind of lost. how can controller action return correct image path image_tag function? doing 'return' doesn't feel right. or somehow directly include image blob generated gruff?

edit:

i've created helper function creates graph , returns file path.

in controller method want return actual image instead of path. writing images disk every request slow. send_data method in rails used this.

send_data(g.to_blob, :filename => "any.png", :type => 'image/png', :disposition=> 'inline') 

g gruff instance. filename doesn't matter @ all. src of image tag should specific controller method generates graph. can use normal url helpers generate this.


Comments