So I have a database structure that looks something like this:
Events:
event_id: :integer
event_type: :string
name: :string
slug: :string
user_id: :integer
start: :datetime
finish: :datetime
and Weddings which I need to inherit from Events:
bride_name: :string
groom_name: :string
street: :string
city: :string
state: :string
zip: :integer
receptions: :text
I want to be able to create a Wedding, or any other event for that matter, and have it inherit the traits that are common among all the events from the Event model. When I tried to do this with STI the Wedding model only had the traits of the Event model. How do I implement this?
This does not work
class Wedding < Event
attr_accessor :receptions, :reception_name, :reception_address, :reception_city, :reception_state, :reception_zip
end
As Rails only supports STI out of the box, if you really want MTI, you can give the ActiveRecord::ActsAs gem a shot.
There are a couple of open issues in their tracker but development seems to be somewhat active.