bypassing normal template rendering?

I have an app that let's a user design a label and see a preview in realtime.

The setup:

The image is generated on a second machine, not the webserver. This second machine is not accessible from the internet, but only from the main webserver, so I can't call it directly in my app. The generated image has to travel between the two machines before going to the client proper. The first machines gets the image from the second machine using an HTTP request.

The issue:

Ideally I'd like to be able just to pass the generated image - which is received over HTTP - directly back to the user client without messing with it. As it is requested over HTTP in the first place, it can be passed back directly, the main webserver just acting as a conduit. The problem is that in RoR, if I use, say, a controller action to call the 2d machine to get the image, RoR wants to render the default template, "fetch_preview" in this case. I think this will change the response from the image-response received from the 2nd machine, to a 'text/html' response. What I'd like to know is if it's possible either to (a) tell RoR to just skip the template rendering entirely for the "fetch_preview" action, skip making a template, and just "put" the response from the 2d machine back to the client; or (b) change how the template rendering works so that it sends the data back as an image.

Here's my code that fetches and sends the image - it's pretty much boilerplate, but for what it's worth:   require 'net/http'   require 'uri'

  url = URI.parse( "http://[url]/image_maker.cgi? img_tid=#{ session[ :img_id ] }&preview=1" )   req = Net::HTTP::Get.new( url.path )   res = Net::HTTP.start( url.host, url.port ) { |http| http.request( req ) }   puts res.body

Thanks Luke, my problem has advanced from the rendering to getting the browser to display the image properly. Investigating send_data options :slight_smile:

The fact that the data is coming from another web server is irrelevant. You are sending out binary data, so you need to use send_data() and set the appropriate mime type (which you can get from the Net::HTTP response). send_data skips() the normal template rendering.