Something that I have noticed is that every class that inherits from
ActiveRecord::Base has a database table of its own.
However what if I don’t want a class to have its own table, but to
actually serve as a proxy to initialize other entries?
For instance as an example, let’s have a form with the fields for
“student name”, “student id number”, “parent’s name”, “street 1”,
“street 2”, “town”, “postcode”, “state”.
There will be (suppose) 2 underlying database tables that will be
populated as a result of this form submission, a table “student_record”
that has “id”, “name”, and “id_number” (not to be confused with “id”, it
is more like “passport number”), as well as another table “contact” with
the fields “parent_name”, “street_1”, “street_2”, “town”, “postcode”,
“state” as well as “student_record_id” which is a foreign key pointing
to the id of the associated “student_record”.
Now, strictly speaking it can be argued that all of these entries can be
put into a single table for simplicity’s sake, but supposing there are
students with multiple parental contacts (perhaps separated, or they
have holiday addresses, etc) and the system is meant to accomodate them,
hence the provision for multiple contacts.
How is it possible to have a “front end” class that acts and works just
like an object by itself (ie, maybe a “student” class), but actually
have no underlying database table of its own and instead exists by
pulling records from associated databases?