This is a separate question, but it is related to an earlier question: Three Column Join in Rails with Active Scaffold. To sum up: Rails automatically looks for a two column join table, but it doesn't do the same for a three column join table. I've tried the suggestions in the previous question, but it comes down to this:
If you have the models Project, Employee, Role and each has a habtm relationship to the other two, rails will do each relationship separately but not as a whole.
class Employee < ActiveRecord::Base
#has_many :employees_projects_roles
#has_many :roles, :through => :employees_projects_roles
#has_many :projects, :through => :employees_projects_roles
has_and_belongs_to_many :roles
has_and_belongs_to_many :projects
end
repeated for Project, Role follows
class Role < ActiveRecord::Base
#has_many :employees, :through => :employees_projects_roles
#has_many :projects, :through => :employees_projects_roles
has_and_belongs_to_many :employees
has_and_belongs_to_many :projects
end
My question is this, since rails looks for employees_projects, projects_roles
, and employees_roles
but not employees_projects_roles
is there a way to alias those names to the real table name and still allow CRUD functionality in the database (MySQL or PostgreSQL)?
[Edit] Whoops. I have got to stop answering and questioning publicly before I've had enough coffee. Changed the commented out portion from hmt to habtm. Included commented out portion of code to reflect the various options I've tried.