0

I'm adding support for recurring events to my Rails app. One of the functions is recurring_event.delete_this_and_following

app/models/recurring_event.rb

   16 class RecurringEvent < ApplicationRecord
   17   belongs_to :event

   32   def delete_this_and_following
   33     event.recurring_events.where("start_time >= ?", start_time).destroy_all
   34   end

Unfortunately this gives me this error:

(byebug) event.recurring_events.where("start_time >= ?", start_time).size
*** ActiveRecord::StatementInvalid Exception: PG::InFailedSqlTransaction: 
ERROR:  current transaction is aborted, commands ignored until end 
of transaction block
: SELECT COUNT(*) FROM "recurring_events" 
WHERE "recurring_events"."event_id" = $1 AND 
(start_time >= '2018-10-23 10:42:50.281315')

nil

Has start_date wrong format? start_time.to_s => "2018-10-23 11:24:59 UTC"

martins
  • 9,669
  • 11
  • 57
  • 85

1 Answers1

0

This is strange. It might have been spring that failed to reload or something. I did a reboot of my machine today and now this works:

event.recurring_events.where("start_time >= ?", start_time).destroy_all

Thanks for the suggestions anyway! :-)

martins
  • 9,669
  • 11
  • 57
  • 85