Skip to content

Error 500 while importing csv with empty fields #18

@ralgozino

Description

@ralgozino

If you tru to import csv with empty cells, the plugin fials with error 500, and you can see the following message in the log:

ActionView::Template::Error (undefined method `force_encoding' for nil:NilClass):
    26:         <% @csv_rows[0].each_with_index do |value, index| %>
    27:           <tr class="<%= cycle('odd', 'even') %> issue child parent">
    28:                     <td> <%= value.force_encoding("utf-8") %> </td>
    29:                     <td> <%= @csv_rows[1][index].force_encoding("utf-8") %> </td>
    30:                     <% @options = params[:options][index] if params[:import] %>
    31:                     <td>
    32:                       <%= select_tag :options, options_for_select(@query, :selected => @options), {:name => "options[]", :prompt => "No Match (Skip)"} 

It would be better to check if the cell is empty before trying to (de|en)code de text.

Regards,
Ramiro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions