My application has an activities database, and I'm trying to use IMGKit to render the show view of an activity as an image file that can be then used on other platforms. I feel like I've implemented IMGKit properly, but all I'm getting is a blank image.
Controller action:
def show
@activity = Activity.find(params[:id])
respond_to do |format|
format.html
format.jpg do
html = render_to_string
kit = IMGKit.new(html)
img = kit.to_img(:jpg)
send_data img, type: "image/jpeg", disposition: "inline"
end
end
end
Not sure if there's anything else applicable?
Edit - this is the view it should be rendering, show.jpg.erb
<body>
<main style="background-color:blue;color:white;">
<h1 style="font-size:20px;"><%= @activity.title %></h1>
<h2>Hello</h2>
</main>
</body>