Skip to content

Commit

Permalink
import identifier and current_shelf_name
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Dec 30, 2019
1 parent 2c6d4b7 commit 01ec461
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/models/inventory_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ def import
file = File.open(self.inventory.path)
reader = file.read
reader.split.each do |row|
item = Item.where(item_identifier: row.to_s.strip).first
identifier = row.to_s.strip
item = Item.find_by(item_identifier: identifier)
if item
unless self.items.where(id: item.id).select('items.id').first
Inventory.create(
inventory_file: self,
item: item
item: item,
current_shelf_name: shelf.name,
item_identifier: identifier
)
end
end
Expand Down

0 comments on commit 01ec461

Please sign in to comment.