"Cool" and mostly crazy hotfix for acts_as_paranoid (pls read as core dev)

https://gist.github.com/ezii123/64913dfed18a175031ea70eeab54ca4c

Refinements didn’t work when tested properly, so I ended up with this construct


def create

Banal::Brainstorm.class_eval do

default_scope lambda { with_deleted }

end

@comment = Comment.new(comment_params)

@comment.save!

redirect_to banal_brainstorms_path

Banal::Brainstorm.class_eval do

default_scope lambda { without_deleted }

end

end

Furtherly refined:


def create

ActiveRecord::Base.transaction do

Banal::Brainstorm.class_eval do

default_scope lambda { with_deleted }

end

@comment = Comment.new(comment_params)

@comment.save!

redirect_to banal_brainstorms_path

Banal::Brainstorm.class_eval do

default_scope lambda { where id: (unscoped.pluck(:id) - only_deleted.pluck(:id)) }

end

end

end