I posted something about this a week ago wihtout response, but have made
some
progress since. However, I’m still not getting exactly what I want.
OK, three core tables:
create_table :reference_items do |t|
t.column :title, :string, :limit => 255
t.column :year, :integer, :limit => 4
t.column :type, :string
t.column :container_id, :integer
t.column :collection_id, :integer
t.column :original_id, :integer
t.column :event_id, :integer
end
create_table :contributors do |t|
t.column :type, :string, :default => "Person"
t.column :sort_name, :string, :limit => 255, :null =>
false
end
create_table :contributions do |t|
t.column :reference_item_id, :integer
t.column :agent_id, :integer
t.column :type, :string
t.column :position, :integer
end
Drawing on this article …
http://blog.hasmanythrough.com/articles/2006/02/28/association-goodness
… I have no problem using the through relation to be able to do stuff
like:
some_refitem.contributors.first.sort_name
Where I get stuck is that I need to be able to subclass contributions so
that I
can do stuff like:
some_refitem.authors
some_refitem.translators
So I need to be able to essentially treat each subclass as a list.
Can STI + through associations currently handle this, and is yes, how?
If not, any suggestions on how to achieve what I’m after?
Bruce