Check out example codes for "ruby on rails csv import". It will help you in understanding the concepts better.

Code Example 1

// Model
require 'csv'

def self.import(file)
    CSV.foreach(file.path, headers: true) do |row|
      to_hash = row.to_hash

      // Deal with to_hash header and data. Example Create
      user = create(
                          name: to_hash['name'], 
        				  email: to_hash['email'], 
        				  lastname: to_hash['lastname']
                        )
    end
end


// Controller
def import
   Model.import(params[:file])
end

// View
= form_tag route_path, multipart: true, remote: true do
	= file_field_tag :file,
	= button_tag 'Import'

Learn ReactJs, React Native from akashmittal.com