jeudi 2 octobre 2014

Delayed Job - undefined method `name' for nil:NilClass


Vote count:

0




I'm struggling with this error. I've got a controller action like so:



def import
InventoryItem.import_list(params[:file], current_vendor.id)
redirect_to vendors_dashboard_path, notice: "Inventory Imported"
end


My class method:



class << self
def import_list(file, vendor_id)
vendor = Vendor.find(vendor_id)
SmarterCSV.process(file.path,
{:key_mapping => { vendor.import_preference.brand_symbol => :brand,
vendor.import_preference.product_symbol => :product,
vendor.import_preference.price_symbol => :price,
vendor.import_preference.upc_symbol => :upc}}) do |row|

params = row.first.merge(:store_id => vendor.stores.first.id)
inventory_item = InventoryItem.create(params)
end
end
handle_asynchronously :import_list
end


When I try and execute, I get the undefined method error. This method works without calling handle_asynchronously and when I make this a normal self.import class method. What am I doing wrong here?



asked 3 mins ago







Delayed Job - undefined method `name' for nil:NilClass

Aucun commentaire:

Enregistrer un commentaire