To address the previous question of what a Line is, I'll show an example Quote. Note that the only piece of data in a Line is the words spoken (between "), and the only piece of data in a Person is the person's name. This example does not feature tags.
Allen: "Is that you, Nick?"
Justin and Nick: "This is UNIX, I know this!"
So a "quote" is often an exchange between multiple parties consisting of multiple lines.
I want to be able to retrieve
- Arbitrary quotes
- All quotes in which a given person appears
- All tags for a given person
- All tags for a given quote
- All quotes for a given tag
It looks like the following will work. Thoughts?
Code Ruby:
class Quote < ActiveRecord::Base
has_many :lines
has_many :taggings
has_many :tags, :through => :taggings
has_many :people, :through => :lines, :source => :says
has_many :yays
has_many :nays
end
class Line < ActiveRecord::Base
belongs_to :quote
has_many :says
has_many :people, :through => :says
end
class Person < ActiveRecord::Base
has_many :says
has_many :lines, :through => :says
has_many :quotes, :through => :lines, :source => :says
has_many :tags, :through => :quotes, :source => :taggings
end
class Tag < ActiveRecord::Base
has_many :taggings
has_many :quotes, :through => :taggings
has_many :people, :through => :quotes, :source => :taggings
end
class Tagging < ActiveRecord::Base
belongs_to :quote
belongs_to :tag
end
class Say < ActiveRecord::Base
belongs_to :person
belongs_to :line
end
class Yay < ActiveRecord::Base
belongs_to :quote
end
class Nay < ActiveRecord::Base
belongs_to :quote
end
Bookmarks