https://avo.cool logo
boolean_group computed options
# general
m
I think I have found a bug in the
boolean_group
field type, specifically computed options: I found that if I try to update a record from computed options derived from the
record
it does not work. I chased that down to the fact that when I add a breakpoint in the field's computed options lambda and issue a PUT, there,
record
is nil:
Copy code
rb
    field :event_roles,
          as: :boolean_group,
          options: -> do
      binding.irb
      record&.event&.roles || {}
    end
=>
Copy code
irb(#<Avo::ExecutionContext:0x000...):007> record
=> nil
note that this is not the case when it's called regularly from the
edit
view. it also works as expected with options supplied as a regular hash
so, definitely
record
is nil here: https://github.com/avo-hq/avo/blob/main/lib/avo/fields/boolean_group_field.rb#L11 when in the
update
action
the only question is whether that's by design?
further down the rabbit hole, this line assigns
nil
to `@record`: https://github.com/avo-hq/avo/blob/main/app/controllers/avo/base_application_controller.rb#L192
l
Hi @millions-exabyte-27721
Try
resource.record
m
ah okay... wild
would you care to elaborate...?
l
I'm debugging
It seems that the field is not properly hydrated on update
This PR will fix this issue https://github.com/avo-hq/avo/pull/3808
2 Views