How can show message error in a view, when upload a excel file?
<p>I'm trying to show a message on the new view</p>

<p>Here the live demo:</p>

<pre><code>http://code.runnable.com/VrUvfZPOiiVooTAU/importing-excel-files-for-ruby-on-rails
</code></pre>

<p>Here is the controller:</p>

<pre><code>def new
end

def create
   @errors = User.import(params[:file])          
   if @errors.present? 
     render :new;
     return; 
   end
end
</code></pre>

<p>Here is the view</p>

<pre><code> Import
 &lt;%= form_tag user_management_users_path, multipart: true do %&gt;
  &lt;%= file_field_tag :file  %&gt;
  &lt;%= submit_tag "Import" %&gt;
 &lt;% end %&gt;


 &lt;% if @errors %&gt;
   &lt;% @errors.each do |message| %&gt;
     &lt;%= message %&gt; 
   &lt;% end %&gt;
 &lt;% end %&gt;
</code></pre>

<p>Here is the model:</p>

<pre><code>def self.import(file)
 @errors = []
 spreadsheet = open_spreadsheet(file)
  (2..spreadsheet.last_row).each do |i|  
      name     = spreadsheet.cell(i,'A')    
      lastname = spreadsheet.cell(i,'B')
      doc_nat  = spreadsheet.cell(i,'C')

      user = User.create(:name =&gt; name,
                                 :lastname =&gt;lastname,
                                 :doc_nat =&gt;doc_nat)
      if user.save
        # stuff to do on successful save 
      else
        user.errors.full_messages.each do |message|
          @errors &lt;&lt; "Issue line #{i}, column #{message}"
        end
      end

 end    
end

def self.open_spreadsheet(file)
  case File.extname(file.original_filename)
  when ".csv" then Roo::CSV.new(file.path, csv_options: {encoding: "iso-8859-1:utf-8"})
  when ".xls" then  Roo::Excel.new(file.path, packed: false, file_warning: :ignore)
  when ".xlsx" then Roo::Excelx.new(file.path, nil, :ignore)
  else raise "Unknown file type: #{file.original_filename}"
end
</code></pre>

<p>end</p>

<p>I'm trying to find the way to show a message indicating the ROW PROBLEM on the index view.</p>

<p>For example I'm adding a user that already exist and want to show a message indicating</p>

<pre><code>ROW 1 already exist
Row 2 is duplicated
Row 1 must be string 
or something like that 
</code></pre>

<p>But after uploading the excel just getting numbers and not the message:</p>

<pre><code>Issue line 2, column already exist
Issue line 3, column already exist
</code></pre>

<p>Just getting numbers:</p>

<pre><code>2  3
</code></pre>