https://avo.cool logo
Hey folks, I was trying `nested` feature
# general
f
Hey folks, I was trying
nested
feature and was getting `undefined method `klass for nil from this method def model @model ||= @parent_model_class.reflections[@field.name.downcase].klass end, from
avo-advanced (3.19.1) app/components/avo/advanced/nested/field_component.rb:29
, I noticed that I was getting
"purchase order items"
from "@field.name.downcase" instead of purchase_order_items. I think this only works if we have model name without underscore.
l
Hi @flat-television-5571
We detected this error and we're working on it
Thanks for letting us know, this issue will be fixed on the next release
f
@loud-jewelry-99127 thank you. that's awesome .
l
can you share how you're declaring the field ?
f
Sure, in my purchase order resource =>
Copy code
def fields
    field :id, as: :id
    field :supplier, as: :belongs_to, searchable: true
    field :order_date, as: :date, default: -> { Date.today }
    field :purchase_order_items, as: :has_many, nested: true
  end
, and in my purchase order item resource =>
Copy code
def fields
    field :id, as: :id
    field :purchase_order, as: :belongs_to
    field :product_unit, as: :belongs_to,
          can_create: false,
          searchable: true
    field :quantity, as: :number
    field :product_unit_prices, as: :has_many, attach_scope: -> { query }, hide_on: [:index], name: "Prices"
  end
.
l
Thanks
f
It seems to work if I define it like this
field :purchase_order_items, as: :has_many, nested: true, name: 'purchase_order_items'
l
Yes, that's not ideal
A propper fix is being pushed and released soon
f
Awesome, thanks again @loud-jewelry-99127
l
Anytime @flat-television-5571 This issue should be fixed on
3.19.2
could you please confirm? Thank you!
f
@loud-jewelry-99127 It working perfectly! Thank You.
l
Cool!