Skip to content

Conversation

@jimmynguyen
Copy link
Contributor

What is the goal of this PR and why is this important?

The goal of this PR is to address the error where an organization does not persist when added to a user.

How did you approach the change?

I identified that the root cause of the persistence error is that the project_user record was being silently rejected when the title field is left blank due to the user model definition.

awbw/app/models/user.rb

Lines 45 to 46 in 4488ab8

accepts_nested_attributes_for :project_users, allow_destroy: true,
reject_if: proc { |attrs| attrs["project_id"].blank? || attrs["title"].blank? }

I updated the user model to validate the project_users and added a missing validation for the title field on the project_user model.

I updated the rejected_if logic for project_users on the user model to ignore records where project_id and title are both blank.

I updated the Organization input so that the error validation works as expected.

Anything else to add?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Adding an organization to a user does not persist

1 participant