Ruby on Rails Monday, August 8, 2016



THe part of code is:

  def downloadCSV
    require 'csv'
    @ary = session[:ary]
    csv_string= CSV.generate do |csv|
        @ary.each do |t|
        csv << [t]
        end             
    end           

    send_data csv_string,
    type: 'text/csv; charset=iso-8859-1; header=present',
    disposition: 'attachment', filename: 'rannumgenerator.csv'

  end

The web applet link is:

http://methodologymedia.psu.edu/most/rannumgenerator/index

You can enter 1000 for N and 13 for C, click compute, get a result page,
which has 

Download: CSV | Excel

the code above is used for downloading CSV file after click CSV, which works
in rails 4.2.0, now instead of showing the download dialog, all numbers displayed 
in the page.

Thanks!
Liz


On Monday, August 8, 2016 at 4:15:44 PM UTC-4, Colin Law wrote:
On 8 August 2016 at 19:25, Liz Huang <liyhu...@gmail.com> wrote:
>
>
> Hi,
>
> Recently I just upgrade rails from 4.2.0 to 5.0.0, wonder what I need to do
> to
> make send_data downloadable file working again? Now the data displayed in
> page instead of downloadable file as before?

You need to post the bit of code that is failing so we can see what
you are doing.  We are not telepathic.  Not large chunks of code just
the bit that is failing. Tell us what you expect that bit of code to
do and what it actually does.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c297cbe8-0de2-482c-93d2-507b7c722a11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment