Let's say I have a Company that has many Employees and each Employee can have many Companies.
Basically I will have :
class Employee < ActiveRecord::Base
has_and_belongs_to_many :companies
end
and
class Company < ActiveRecord::Base
has_and_belongs_to_many :employees
end
But then I'm confused about how I could get things like:
All the employees of a company with the name starting by "John"
All the employees of a company order by name first, email second.
Is there some magic I don't know about? The example is just here for the demo, feel free to make assumptions or change it if it helps you explain better.