Hello guys!! I am facing a strange behavior, i don...
# avo-2
q
Hello guys!! I am facing a strange behavior, i dont know if is a bug or miss configuration, i have try a lot of things.
Copy code
ruby
class User < ApplicationRecord
  has_one :consumer, dependent: :destroy
  has_one :power_plant, through: :consumer
end


class Consumer < ApplicationRecord
  belongs_to :user
  belongs_to :power_plant, optional: true
end


class PowerPlant < ApplicationRecord
  has_many :consumers, dependent: :nullify
end
When i try to detach a power_plant from user in avo destroy the model consumer too, like:
User.first.power_plant=nil
destroy consumer.
User.first.power_plant.destroy!
works, destroy only de power_plant.
l
Hey @quaint-pencil-2979
can you create a reproduction app which I can try on my machine?
also, with some instructions on what you're doing in Avo?
q
I was looking deep, i think is not a AVO bug
Its a rails bug, i will publish in rails github
l
🙌👌
if you figure it out, please post the solution here too 😅
2 Views