ruby on rails - How to include criteria from a different model to a where clause? -


i have 2 models: employee , vote

employee has_many votes vote belongs_to employee 

the employee model has badge_number attribute.

how can retrieve votes belong employees badge numbers greater 1000?

this work if employees table named according rails conventions.

vote.joins(:employee).where('employees.badge_number > 1000') 

since name employee, work:

vote.joins(:employee).where('employee.badge_number > 1000') 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -