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

HER-50 Create Organization Model #40

Merged
merged 7 commits into from
Jan 5, 2025
Merged

Conversation

mhope21
Copy link
Collaborator

@mhope21 mhope21 commented Jan 4, 2025

HER-50: Create Organization Model

Issue

https://raquelanaroman.atlassian.net/browse/HER-50

Description

As a user, I want to associate users/be associated with an organization so that the system can clearly represent relationships between individuals and the entities they belong to.
Each organization should be allowed to have multiple users and an address. Organizations should have a name and type, with support for different organization types. The address for each organization will use the existing polymorphic association in the Address model.

Acceptance Criteria
Create an Organization model with the following attributes: name: string, required, org_type: integer, default: 0, null: false.

Associate organization with:
Users: An organization should have many users.
Address: Use the polymorphic Address association, where addressable_type is Organization.

Validate the presence of name and org_type.

Add a test to ensure the polymorphic Address relationship works with Organization.

Implementation
Generate the Organization Model:

rails generate model Organization name:string org_type:integer

Add Associations to the Organization Model

has_many :users
has_one :address, as: :addressable

validates :name, presence: true

enum org_type: {
  school: 0,
  agency: 1,
  nonprofit: 2,
  other: 3
}

Update the User Model
Ensure the User model has belongs_to :organization, optional: true

Write tests to verify that it functions properly.

https://raquelanaroman.atlassian.net/browse/HER-4

Changes

  1. Create Organization model.
  2. Define relationships in the model.

Review Checklist

  • I have documented my code with code comments.

Copy link
Collaborator

@olesiamironenko olesiamironenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some suggestions to the code. Can you let me know what you think, please?

@olesiamironenko olesiamironenko self-requested a review January 4, 2025 21:04
Copy link
Collaborator

@olesiamironenko olesiamironenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I have only one question about the new schema: should the Donations table have sripe related columns or not?

Copy link
Collaborator

@trca831 trca831 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@mhope21
Copy link
Collaborator Author

mhope21 commented Jan 5, 2025

Looks good.

I have only one question about the new schema: should the Donations table have sripe related columns or not?

It should not, Raquel removed them when she did her PR, I guess because she knows we are not going to get to that part of the wishlist. I will check and see if I still have them.

@mhope21 mhope21 merged commit 196d71f into main Jan 5, 2025
3 checks passed
@mhope21 mhope21 deleted the HER-50-Create-Organization-Model branch January 5, 2025 21:35
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.

3 participants