Skip to content

resource.record nil in a field block (association) #2544

@jetienne

Description

@jetienne

Describe the bug

Upgrade from 3.4.1 to 3.4.2 broke the following code, the resource record is always nil.

  field :state, as: :badge, options: {
        info: 'sent',
        success: 'accepted',
        danger: 'refused'
      }, name: '', visible: lambda {
        resource.record.state.in?(%w[accepted refused])
      }

The exception is undefined method state' for nil`.

By just replacing 3.4.1 to 3.4.2 in the same environment (just reloading the page) it fails.

Our models are Deal has_many Proposaland it fails on a deals#show with has_many :proposals having the field state.

We had to revert our production because of this bug.

System configuration

Avo version:
3.4.2

Rails version:
7.1.3.2

Ruby version:
3.3.0

License type:

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Impact

  • High impact (It makes my app un-usable.)
  • Medium impact (I'm annoyed, but I'll live.)
  • Low impact (It's really a tiny thing that I could live with.)

Urgency

  • High urgency (I can't continue development without it.)
  • Medium urgency (I found a workaround, but I'd love to have it fixed.)
  • Low urgency (It can wait. I just wanted you to know about it.)

(we cannot upgrade until it's fixed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions