title: Validation of uploaded Excel file before save using Rails with Roo-xls gem
body: <p>In a model, before uploading an <code>.xls</code> file, I want to be able to validate excel files before they are saved by the application. I am trying to open the to-be-saved excel file from the <code>:file_url</code> object(column in comits table where the <code>.xls</code> files will be saved) and then validate it but I am getting a <code>no implicit conversion of Symbol into String</code> error. </p>
  
  <p>The validation works when I place the actual file path of an excel file that has been uploaded and saved by carrierwave into <code>Roo::Excel.new("")</code> but that defeats the purpose of my validation.  </p>
  
  <p>How can I grab the excel file without it being stored in the application?</p>
  
  <p>I appreciate the help! I hope is not too confusing. </p>
  
  <p>This is my <code>comit.rb</code>
  </p>
  
  <pre><code>class Comit &lt; ActiveRecord::Base
    belongs_to :user
    mount_uploader :file_url, ComitUploader, mount_on: :file_url
    validates :filename, :file_url, presence: true
    validates_format_of :file_url, with: /.xls/, message: "Wrong file format"
    before_save :validate_excel
  
    def validate_excel
      sheet = Roo::Excel.new(:file_url)
      errors = []
  
      header = sheet.row(1)
      num_of_columns = sheet.last_column
  
      errors &lt;&lt; 'Need headers' unless
      errors &lt;&lt; 'Need more columns' if num_of_columns &lt; 21
  
      errors
    end
  end
  </code></pre>