Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validations not showed when attaching fails #2883

Closed
4 of 11 tasks
krystof-k opened this issue Jun 21, 2024 · 7 comments · Fixed by #3002
Closed
4 of 11 tasks

Validations not showed when attaching fails #2883

krystof-k opened this issue Jun 21, 2024 · 7 comments · Fixed by #3002
Assignees
Labels
Bug Something isn't working

Comments

@krystof-k
Copy link
Contributor

Describe the bug

When attaching an association using :through, Avo doesn't show validation errors, only reloads the associations table.

Steps to Reproduce

Have field like this:

class Avo::Resources::Subscription < Avo::BaseResource
  def fields
    field :plan_variants,
      as: :has_many,
      through: :subscription_items
  end
end

Validation in the model:

class SubscriptionItem < ApplicationRecord
  belongs_to :subscription
  belongs_to :plan_variant

  validate :fail

  private

  def fail
    errors.add(:plan_variant, "already added to the subscription")
  end
end

Try to attach the record and it doesn't show the validation error.

Expected behavior & Actual behavior

Validation error is shown.

System configuration

Avo version:
3.9.1
Rails version:
7.0.8.1
Ruby version:
3.2.3
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.)
@adrianthedev
Copy link
Collaborator

I think it's a bug and Avo swallows that error.
We'll have a fix in the first half of next week.

@adrianthedev adrianthedev added the Bug Something isn't working label Jun 22, 2024
@adrianthedev
Copy link
Collaborator

Please try it tomorrow with Avo 3.10 to see if this is fixed.

@adrianthedev
Copy link
Collaborator

This PR should have fixed that
#2905

Closing for now to keep the issue queue clean. Please re-open if this persists after tomorrow.

@krystof-k
Copy link
Contributor Author

Just tested it in 3.10.5 and still the same case – no validation error, no message (actually now it reloads the whole page, not just the table as before if I remember correctly).

@adrianthedev
Copy link
Collaborator

hmmm. we'll need a reproduction repo.
I understand it might not be easy to make, but it's the only way we can run and troubleshoot the issue.

@adrianthedev adrianthedev reopened this Jul 15, 2024
@adrianthedev adrianthedev added Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution. and removed Bug Something isn't working labels Jul 15, 2024
@krystof-k
Copy link
Contributor Author

krystof-k commented Jul 15, 2024

@adrianthedev hopefully I managed to do it here. (Just try to attach a team to a user.)

@adrianthedev adrianthedev added Bug Something isn't working and removed Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution. labels Jul 15, 2024
@adrianthedev
Copy link
Collaborator

Ok. Thanks! We'll have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants