mercredi 20 juillet 2016

ActiveRecord::AssociationTypeMismatch gotNilClass

I am a beginner programmer in Ruby and Ruby on Rails , I'm trying to run a rake command in my task , but when I do the following happens:

rake daily_tasks:process_api

rake aborted! ActiveRecord::AssociationTypeMismatch: State(#47392639701120) expected, got NilClass(#47392580444120) /home/thiagoamaralr/Desktop/proponente-master-74f8a3b2ddb02a90b2c173cf31383505018d02dd/app/services/create_programa_api.rb:21:in call' /home/thiagoamaralr/Desktop/proponente-master-74f8a3b2ddb02a90b2c173cf31383505018d02dd/lib/tasks/daily_tasks.rake:7:inblock (3 levels) in ' /home/thiagoamaralr/Desktop/proponente-master-74f8a3b2ddb02a90b2c173cf31383505018d02dd/lib/tasks/daily_tasks.rake:5:in each' /home/thiagoamaralr/Desktop/proponente-master-74f8a3b2ddb02a90b2c173cf31383505018d02dd/lib/tasks/daily_tasks.rake:5:inblock (2 levels) in ' Tasks: TOP => daily_tasks:process_api (See full trace by running task with --trace)

Follow the task I'm trying to run:

namespace :daily_tasks do

desc "Process the day to day tasks" task process_api: :environment do

SiconvApi::Programa.find.each do |programa|
  if programa.data_inicio_recebimento_propostas && (programa.data_inicio_recebimento_propostas.to_date >= Date.parse("2015/06/01"))
    CreateProgramaApi.call(SiconvApi::Serializers::Programa.new(programa))
  end
end

Thank you in advance for your attention!

Aucun commentaire:

Enregistrer un commentaire