jeudi 8 septembre 2016

Rails Search a field from another table

i have this sentence in my model

class Curso

     def self.search(username)
        where("LOWER(curso.user.name) LIKE ?", "%#{username}%")
     end

i want to bring the name of an user from the table user. A 'curso' belongs to an user.

do you know which can be the query?

thanks!

Aucun commentaire:

Enregistrer un commentaire