rails multiple outer joins syntax
- by Craig McGuff
I have the following models
user
has_many :leave_balances
leave_balance
belongs_to :user
belongs_to :leave_type
leave_type
has_many :leave_balances
I want to output a table format showing user names and their balance by leave type.
Not every user can have every balance i.e. outer joins required.
I'd like to see something like this:
Employee Annual Leave Sick Leave
Bob 10
Fred 9
Sara 12 15
I am unsure how to get this out as a single statement?
I am thinking something like User.joins(:leave_balances).joins(:leave_type)