rails: has_many :through + polymorphism validation?
- by ramonrails
I am trying to achieve this. Any hints?
A project has many users through join model
A user has many projects through join model
Admin class inherits User class. It also has some Admin specific stuff.
Admin like inheritance for Supervisor and Operator
Project has one Admin, One supervisor and many operators.
Now I want to
1. submit data for project, admin, supervisor and operator in a single project form
2. validate all and show errors on the project form.
Project has_many :users, :through = :projects_users
User has_many :projects, :through = :projects_users
ProjectsUser = :id integer, :user_id :integer, :project_id :integer, :user_type :string
ProjectUser belongs_to :project, belongs_to :user, :polymorphic = true
Admin < User
Supervisor < User
Operator < User
Is the approach correct? Any and all suggestions are welcome.