title: "TypeError: no implicit conversion of Array into String" when try to move file into another folder after upload files in Ruby on Rails
body: <p>I'm facing a complexity about file moving in Ruby on Rails.</p>
  
  <p>I want to move the file to another folder after finished uploading, here is my code snippet</p>
  
  <pre><code>def create
      file = Dir.glob("#{Rails.root}/public/files/**/*.csv")
      file.each do |filesrc|
          # =&gt; get file name
          file_name =  File.basename(filesrc, ".csv")
          # =&gt; get use_id from file name
          user_id = file_name.scan(/\d+/).first
          # =&gt; send request for upload into model
          History.import(filesrc, user_id)
  
          #=&gt; for moving this file
          dest = Dir.glob("#{Rails.root}/public/files_old/")
          FileUtils.mv(filesrc, dest)
      end
  end
  </code></pre>
  
  <p>that is my code &amp; it's working properly for importing to DB but after that not moving to <code>histories_old</code> and showing below error</p>
  
  <blockquote>
    <p>TypeError: no implicit conversion of Array into String</p>
  </blockquote>
  
  <p>What I'm doing wrong with this code?</p>
  
  <p>Really appreciate if solve this issue.</p>
  
  <p>Thanks.</p>