Polymorphic belongs_to

I am creating an appointment system where appointments can be made for
current users or for non-registered users. I need a way to create a
appointment that references a client with polymorphic association. I
use a PlaceholderUser object to create a placeholder user that just
has a name, and no other functionality.

I have:
Appointment
appt_time
client_id
client_type

User
name
other attributes

PlaceholderUser
name

I want to be able to use @appointment.client and @appointment.client=
to assign a client as either an User or a PlaceholderUser. Is there a
way to do this without defining ‘client’ and ‘client=’ as class
methods?

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