не Попытку загрузить файл, используя замедленную работуЗадержка работы возвращается без ошибок метода []
def import
@report = current_user.reports.create!(name: params[:report_name])
@contact = @report.contacts.delay.import(params[:file], params[:info_type])
flash[:success]= "Contacts importing, check back in 2-3 minutes"
redirect_to contacts_url
end
возвращается:
undefined method `import' for []
Когда я пытаюсь без ассоциации:
def import
@report = current_user.reports.create!(name: params[:report_name])
Contact.delay.import(params[:file], params[:info_type], @report.id)
flash[:success]= "Contacts importing, check back in 2-3 minutes"
redirect_to contacts_url
end
I получить:
undefined method `name' for nil:NilClass
Импорт:
def self.import(file, info, report_id)
CSV.foreach(file.path) do |row|
input = row*""
# input = hashy["input"]
case info
when "email"
begin
contact_hash = FullContact.person(email: input)
if contact_hash.status = 200
Contact.create!(input: input, contact_hash: contact_hash.to_json, info_type: info, found: true, pending: false, report_id: report_id)
elsif contact_hash.status = 202
Contact.create!(input: input, contact_hash: contact_hash.to_json , info_type: info, found: true, pending: true, report_id: report_id)
end
rescue FullContact::NotFound
Contact.create!(input: input, contact_hash: nil, info_type: info, found: false, report_id: report_id)
rescue FullContact::Invalid
end
when "telephone"
begin
Contact.create!(input: input, contact_hash: FullContact.person(phone: input).to_json, info_type: info, report_id: report)
rescue FullContact::NotFound
Contact.create!(input: input, contact_hash: "Not Found", info_type: info, report_id: report)
rescue FullContact::Invalid
end
end
end
end
Я также не то, что я использую gmaps4rails драгоценный камень, который по умолчанию столбцы широта, долгота и GMaps в ноль, пока контакт не будет сохранен в базе данных. Вот почему?
Где этот 'импорт' определен? Вы уверены, что сообщение об ошибке происходит из-за метода 'import'? Как выглядит метод отложенной работы 'import'? – lurker
всегда отправляйте столбец ваших ошибок. из того, что вы пишете, я думаю, что вы должны перечитать документацию delayed_job. он обычно использует метод '.delay' на экземпляре модели типа' @ user.delay.something'. поэтому 'something' будет методом класса' User', и этот класс настроен для работы с DJ – phoet
@phoet, где я могу найти столбец ошибок? –