views:

27

answers:

1

So I want to dynamically generate a MIDI file on a web request.Coming from the Java world, I expected something to the tune of

class MidisController < ApplicationController
  before_filter :set_content_type    
  def set_content_type
    @headers["Content-Type"] = "audio/midi; charset=utf-8"
  end

  def show
    midi_data = get_midi_data 
    response.write(midi_data)
  end

But the API says, stay away from the response object. Any ideas ?

+2  A: 

Look at the Rails docs for send_file or send_data. It handles all of the header requirements for you.

Peer Allan