I'm not strong in sql and relatively new to rails. The
Case
attr_accessible client_id
belongs_to Client
Client
attr_accessibe name
has_many Cases
I can query directly by client_id and get a record back as expected
Case.where(client_id: 1)
But I would like to query by client.name
Case.where(client.name => "Foo")
This give me an error that tells me that client is not a method of case.
Undefined method or local variable
Ultimately, what I'm trying to do is very simple: get the first Case that belongs to client "Foo". The query I would expect to use is this.
Case.where(client.name => "Foo").first
What should it be?