Class: InventoryFile
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- InventoryFile
- Defined in:
- app/models/inventory_file.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.per_page ⇒ Object
11 12 13 |
# File 'app/models/inventory_file.rb', line 11 def self.per_page 10 end |
Instance Method Details
#import ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/inventory_file.rb', line 15 def import self.reload file = File.open(self.inventory.path) reader = file.read reader.split.each do |row| item = Item.where(:item_identifier => row.to_s.strip).first if item unless self.items.where(:id => item.id).select('items.id').first self.items << item end end end file.close true end |