-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edit groups and participants to have a HABTM association
- Loading branch information
1 parent
1a31bcc
commit 23fc209
Showing
25 changed files
with
341 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Group < ApplicationRecord | ||
belongs_to :user_admin, class_name: "User::Admin" | ||
has_many :participants | ||
belongs_to :user_admin, class_name: "User::Admin", dependent: :destroy | ||
has_and_belongs_to_many :user_participants, class_name: "User::Participant", association_foreign_key: :user_participant_id, inverse_of: :user_participant | ||
# Rever associação | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
class User::Participant < ApplicationRecord | ||
belongs_to :group | ||
module User | ||
class Participant < ApplicationRecord | ||
belongs_to :user_admin, class_name: "User::Admin" | ||
has_and_belongs_to_many :groups, foreign_key: :user_participant_id, inverse_of: :user_participant | ||
# has_many :user_admins, through: :groups | ||
|
||
validates :first_name, :last_name, :birth_date, presence: true | ||
validates :first_name, :last_name, :birth_date, presence: true | ||
end | ||
end |
Oops, something went wrong.