How to render row image date without using send_data?

169 Views Asked by At

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
1

There are 1 best solutions below

0
On BEST ANSWER

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.