18 lines
470 B
Ruby
18 lines
470 B
Ruby
class Worker < ApplicationRecord
|
|
# One-to-many relationship with Participants
|
|
has_many :participants, through: :employments
|
|
has_many :employments
|
|
|
|
# Many-to-many relationship with Employers through Participants
|
|
has_many :employers, through: :participants
|
|
|
|
# Validations
|
|
validates :first_name, presence: true
|
|
validates :last_name, presence: true
|
|
|
|
# Method to return the full name of the worker
|
|
def full_name
|
|
"#{first_name} #{last_name}"
|
|
end
|
|
end
|