That sounds like single inheritance? Except without a type field?
I actually could have used single table inheritance in my code, but thought the two relations I wanted to store, "carpools" and "carpool notification erquests", were distinct enough that they belonged in different schemas. Also, I wanted to avoid having NULL fields. Here's the relevant migration:
create_table "carpool_notification_requests" do |t| t.column "email", :string, :default => "", :null => false t.column "starting_city_id", :integer, :default => 0, :null => false t.column "destination_city_id", :integer, :default => 0, :null => false end create_table "carpools" do |t| t.column "starting_city_id", :integer, :limit => 10, :default => 0, :null => false t.column "destination_city_id", :integer, :limit => 10, :default => 0, :null => false t.column "leave_at", :time, :null => false t.column "return_at", :time, :null => false t.column "email", :string, :limit => 70, :null => false t.column "notes", :text end
And the subclassing model: class CarpoolNotificationRequest < Carpool set_table_name 'carpool_notification_requests'
# Carpool has validation which don't make sense here def validate end
end
The reason I subclassed Carpool was to inherit its belongs_to relations and some of its methods.
I hope this helps!