I apologize if the answer to this question is going to be rudimentary,
but I am thus far stymied by the information I have found on the web.
This seems like it should be simple, but I haven't really found an
example of how to do this yet.
I have a model called Account which has a belongs_to reference to
another model, User, as below:
class Account < ActiveRecord::Base
belongs_to :primary_user, :class_name =>
"User", :foreign_key => "primary_user"
The User model has a property "last_name" and the Account model has a
property "account_name". I want to create a query to find all
accounts by the account's name (account.account_name) and by the
primary user's last name (account.primary_user.last_name). Is there a
best-practice way to write a query like this?