leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 213 forks source link

RuntimeError: Cannot read file #183

Closed aliw77 closed 10 years ago

aliw77 commented 10 years ago

CSV export works flawlessly in dev, but in production it is creating a filename which has HTML elements from the page it is rendered on... and therefore unable to find the file. The error i get is:

RuntimeError: Cannot read file /tmp/aging20140929-5253-rc46sa<div class='row'> <div class='col-md-12 text-right'> <p class='text-right'> <small class='user-grid-update-time'> Updated: 1 minute ago (in 6 sec.) </small> </p> </div> </div>

The controller code for this grid is:

    @course = @org.courses.find(params[:course_id])
    @users = AgingReport.find_users(@org, @course)

    opts = {
      :per_page => 25,
      :order => 'days_since_last_activity',
      :order_direction => 'desc',
      :enable_export_to_csv => true,
      :name => 'aging',
      :csv_field_separator => ',',
      :csv_file_name => Time.now.strftime("%Y%m%d-%H%M")+"_" + @course.title.gsub(/[^0-9A-z.\-]/, '_') + "_pending_completion",
      :custom_order => {
        'users.xid' => 'percent_complete',
        'users.xid' => 'days_since_last_activity'
      }

    }
    @aging_grid = initialize_grid(@users, opts)

    export_grid_if_requested
aliw77 commented 10 years ago

solved - there were non-grid items being rendered in the template, removed them and now it only contains column definitions as per the documentation.