Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.31 KB | None | 0 0
  1. class Part < ActiveRecord::Base
  2.  
  3.   def self.import_csv(file)
  4.     CSV.foreach(file) do |row|
  5.       part = Part.new(
  6.         :pn             => row[0],
  7.         :description    => row[1],
  8.         :list_price     => row[2],
  9.         :cost           => row[3]
  10.       )
  11.       part.save!
  12.     end
  13.   end
  14.  
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement