avo-hq / avo

Build Ruby on Rails apps 10x faster
https://avohq.io
Other
1.47k stars 230 forks source link

Attach Association Errors #2945

Closed ShroukAbozeid closed 1 month ago

ShroukAbozeid commented 2 months ago

Feature

Show error raised during attaching association in avo show view

Additional context

example :

class Event < ApplicationRecord
  has_many :participating_teams, dependent: :destroy
  has_many :teams, through: :participating_teams
end
class ParticipatingTeam < ApplicationRecord
  belongs_to :event
  belongs_to :team

  validates :team_id, uniqueness: { scope: :event_id}
end
class Team < ApplicationRecord
  has_many :participating_teams, dependent: :destroy
  has_many :events, through: :participating_teams
end
 avo/resources/event.rb
   field :teams, as: :has_many, through: :participating_teams

Steps

  1. admin goes to event user page
  2. admin click on attach team and choose team 1
  3. admin click on attach team again and choose same team
  4. error happens while attaching due to unique validation errors

Requested feature: View the validation error message

Actual scenario: The page is refreshed and team not attached and no message shown

Repo link https://github.com/ShroukAbozeid/avo-admin-bugs

adrianthedev commented 2 months ago

Could you please set up a reproduction error that raises those errors so we can tailor the code to that?

adrianthedev commented 2 months ago

We'll wait for the reproduction repository which we can run.

ShroukAbozeid commented 1 month ago

Hello @adrianthedev i've updated the description with reproduction repo

adrianthedev commented 1 month ago

Cool we'll have a look! Thank you!

Paul-Bob commented 1 month ago

Fixed by https://github.com/avo-hq/avo/pull/3002