ruby on rails - How to order associated columns case insensitive -


i'm trying order projects customer company names, error: pg::undefinedtable: error: missing from-clause entry table "customers" line 1: ... "projects"."archived" = $1 order lower(customers.... ^ : select "projects".* "projects" "projects"."archived" = $1 order lower(customers.company) asc.

this how tried far:

projects = project.includes(:customer).order("lower(customers.company) asc") 

if leave out lower(…) works fine.

you need write using references.

project.includes(:customer)        .order("lower(customers.company) asc")        .references(:customers) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -