rescuedcode/StaffPlan — comment on commit 1a79b6728f5a267f6ba914ea1f92c87b2cb05f01
File:  line 0
By Veejay:

Interesting question about HABTM with join tables:

In the case of users and companies, there's a simple way to retrieve the users belonging to a given company, something to the effect of:
```ruby
find_by_sql("SELECT users.* FROM users INNER JOIN companies_users user_id WHERE company_id = ?", user.current_company_id)
```
Yet, because that join table has no model, I can't think of a Arel-style query to express that bit of code in a RDBMS-agnostic fashion (i.e. one cannot do User.joins("companies_users").where....)