views:

31

answers:

1

Situation:

  • There is a Project Resource that has many Resources A each of them having many Resources B
  • When a new Project is created it shall already start with clones of Resources A having clones of Resources B
  • There shall be a Reference Project whose Resources A and B (through A) are cloned from
  • Cloning is done because in this way new Projects can update their resources A and B without changing the Reference Project and vice versa

Question:

  • How to implement this in Rails?

Ideas:

  • Implement a singleton class ''ReferenceProject < Project'' which inherits from Project
    • But STI would be overdone for just one Object?
  • Introduce a new column "is_reference_project" to Project
    • But how to ensure that there is only one?

Thanks for any input! duddle

A: 

I am now doing it this way:

  • Adding a column to Project called "is_reference" (:boolean)
  • Validating on model level that there is only one at the same time according to:
  • Adding named_scopes for the Project model
  • Adding a ReferenceProjects Controller operating on named_scope
duddle