Skip to content

Instantly share code, notes, and snippets.

@sudodo
Created December 2, 2011 01:08
Show Gist options
  • Save sudodo/1421152 to your computer and use it in GitHub Desktop.
Save sudodo/1421152 to your computer and use it in GitHub Desktop.
create and send file dynamically by rails
class MyController < ApplicationController
def get_text
data = "generated by rails controller"
send_data(data, :filename => "rails_generated.txt", :type => "text/plain")
#send_file 'evidence_tmp/tmp.zip', :type => "application/zip" # => when the file already exists.
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment