This Rails application manages employee leave requests, leave balances, and roles, providing a seamless system for tracking and approving time off. Employees can submit leave requests, monitor their leave balances, and administrators can assign roles for access control within the system. Below is a breakdown of the entities and relationships within the application.
👤 User
This represents each system user (typically an employee). Key attributes include:
encrypted_password
, reset_password_token
, etc.otp_secret
and otp_required_for_login
.📈 LeaveBalance
Tracks each user's leave details, including:
User
has one corresponding LeaveBalance
record to keep these details organized.🏖️ LeaveType
Defines the various types of leave available, such as vacation, sick leave, or personal days. Each LeaveRequest
references a LeaveType
.
📝 LeaveRequest
Stores each leave request made by a user, including:
User
can have multiple LeaveRequest
records, and each request is associated with a specific LeaveType
.🔑 Role
Represents different roles within the application (e.g., admin, manager, employee), which determine access permissions for various functionalities within the system.
👥 UserRole
Establishes the many-to-many relationship between User
and Role
. This structure allows:
User
to have multiple Roles
.Role
to be assigned to multiple users.User - LeaveRequest
A one-to-many relationship where a User
can submit multiple LeaveRequest
records.
User - LeaveBalance
A one-to-one relationship where each User
has a single LeaveBalance
record to track their leave details.
LeaveType - LeaveRequest
A one-to-many relationship where each LeaveRequest
references one LeaveType
, and each LeaveType
can be associated with multiple requests.
User - UserRole - Role
A many-to-many relationship facilitated by UserRole
. This setup allows:
User
to be assigned multiple roles, andRole
to be assigned to multiple users.With this structure, the application ensures a user-friendly, organized, and role-based system for managing leaves, user roles, and associated access levels.