Skip to content

Instantly share code, notes, and snippets.

@kyleknighted
Created July 12, 2011 18:30
Show Gist options
  • Save kyleknighted/1078625 to your computer and use it in GitHub Desktop.
Save kyleknighted/1078625 to your computer and use it in GitHub Desktop.
class Mapping < ActiveRecord::Base
belongs_to :user
require "CSV"
has_attached_file :csv_file,
:path => ":rails_root/public/system/mapping/:id/:filename",
:url => "/system/mapping/:id/:filename"
# after_create :create_csv
def get_csv_headers
c = CSV.table(self.csv_file.path)
return c.headers
end
def create_csv
c = CsvFile.new
c.csv_file = self.csv_file
c.save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment