rails: has_many :through validation?

Posted by ramonrails on Stack Overflow See other posts from Stack Overflow or by ramonrails
Published on 2010-03-22T14:49:01Z Indexed on 2010/03/22 22:51 UTC
Read the original article Hit count: 332

Rails 2.1.0 (Cannot upgrade for now due to several constraints) I am trying to achieve this. Any hints?

  1. A project has many users through join model
  2. A user has many projects through join model
  3. Admin class inherits User class. It also has some Admin specific stuff.
  4. Admin like inheritance for Supervisor and Operator
  5. 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 :projects_users ; has_many :users, :through => :projects_users
User has_many :projects_users ; 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
Admin < User # User has 'type:string' column for STI
Supervisor < User
Operator < User

Is the approach correct? Any and all suggestions are welcome.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about object-relational-mapping