Search code examples
ruby-on-railsruby-on-rails-3activerecordsti

Should I split this model and table?


I would like to create simple ResumeBank app.

Issue:

As user I would like to add only two Resumes. Forms for this both Resumes are different with only two fields. Resumes have 12 the same attributes but 2 are diferent.

Question:

Should I split that Resume model and tables to ex: PolishResume and EnglishResume, polish_remsumes and english_remsumes?

Or maybe should I use STI and create PolishResume < Resume and use one table.

What are disadvantages of splitting option?


Solution

  • Seems like classic inheritance should solve it

    class ResumeBase{...}
    class ResumeWith12Forms: public: ResumeBase{
         //use options to determine which unique 2 forms to show
         //options could be an enum or even boolean
         ResumeWith12Forms(options){ };
    }
    
    class User{ std::vector< std::shared_ptr<ResumeBase> userResume; }