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

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -