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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -