0

I am using gruff to create an image. I have created an image and now I have a raw image data. I don't want to use gruff.write('image.png') as I want the application to be fast. I want t be able to display that raw image data on the view.

But the problem is in this: I can't use controllers - so send_data is out of the picture, I guess. Is there a way to use raw image data that I have in my Helper method, and use that helper method to display the image in the view?

module ApplicationHelper

  def generated_image()
    @graph = create_gruff("50x50", "%m/%d") do |g|
      #some code to create a graph
    end
  end
end
Aleks
  • 4,866
  • 3
  • 38
  • 69
  • You could base64 encode the data and put it in a variable, then render the variable value, for example: /> – Ruby Racer Apr 09 '14 at 14:11
  • Hm, interesting, I might give it a try. In the mean time I have created a new controller, created new custom path e.g. /generated_image.jpg and I am re-referencing in my template like `` But I will check further and check your suggestion also. Thanks for the effort – Aleks Apr 10 '14 at 11:38

1 Answers1

0

For now I have one answer on this question, and I am putting it as an answer:

I have created a new controller, created new custom path e.g. /generated_image.jpg and I am re-referencing in my template like

That is how I can render a raw image. There are other options, but for the case I needed this is the option I used.

Aleks
  • 4,866
  • 3
  • 38
  • 69