Firm has_many :clients
Client belongs_to :firm # w Forign key firm_id
I can do client.firm.name
my question:
what is the best way to find clien开发者_Go百科ts that belong to this firm in the same format?
To get all of the client objects, just do...
c = firm.clients
To get all of the client names for a firm as an array of strings, do...
names = firm.clients.all.collect {|c| c.name}
精彩评论