I currently have the following database tables set up:
Departments
ID| Department_name | Manager_ID
Employees
ID| Name | Department_ID
Salaries
ID| Employee_ID | Salary_Amount
The departments table holds information about different departments within the organization. Employees are assigned to specific departments in the employees table, and their salaries are recorded in the salaries table. The manager of each department is also listed in the departments table.
In my web application, I need to display a dropdown list of department names for users to choose from when assigning an employee to a department. However, I want to only show the managers' names as options in the dropdown list if the selected department has a designated manager. If a department does not have a manager assigned, then no manager name should appear in the dropdown list.
Could you suggest the best approach to implement this feature using Ruby on Rails? Essentially, I am looking to conditionally populate the dropdown list based on data stored in the Departments table.