lukaszkups
lukaszkups

Reputation: 5990

saving variable to file and downloading it

I've got a problem with my previous question. Nobody can't help me so I'll try to write better this time what I want:

For couple days I think I've tried everything but I don't really understand how to solve it. Could someone, please write here what methods in model and controller I should write? And all required routes? I'll really appreciate any help. My previous thread (but please do not send me there or give same answers like there): saving file after passing parameter

Upvotes: 1

Views: 639

Answers (1)

lukaszkups
lukaszkups

Reputation: 5990

finally I've found a solution:

def savefile
    @generator = Generator.new(params[:generator])
    @bigtable = Rails.cache.read("pass")
    doc = "wyniki.csv"
    File.open(doc, "w"){ |f| f << @bigtable}
    send_file(doc, :type => 'text; charset=utf-8')
  end

Upvotes: 3

Related Questions