A "virtual model" that encapsulates other models?


Is it possible to have a model in rails that does not exist as a
database table by itself, but it exists solely by pulling data together
from tables used by other models?

For instance, let’s say I have a model of a “customer” which has_many
“addresses”, of which one of the “addresses” is the default address.

So what I’d like to do is to actually have a model, say
“Shipping_Addresses” that pulls “First name” and “Last name” out from
“customer” and sticks it to the rest of the address details as pulled
from “addresses”.

Is this doable?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs