Created
July 17, 2012 19:54
-
-
Save davidrichards/3131617 to your computer and use it in GitHub Desktop.
Just some associations to consider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails g model Title name | |
rails g model IssuesTitle issue_id:integer title_id:integer | |
rails g model Issue name publisher_id:integer illustration | |
rails g model Publisher name | |
rails g model Role name | |
rails g model Person name | |
rails g model PersonRole name issue_id:integer role_id:integer person_id:integer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Issue < ActiveRecord::Base | |
has_many :issues_titles | |
has_many :titles, :through => :issues_titles | |
belongs_to :publisher | |
has_many :person_roles | |
# TODO: Consider CarrierWave http://railscasts.com/episodes/253-carrierwave-file-uploads | |
attr_accessible :name, :publisher_id | |
end | |
class IssuesTitle < ActiveRecord::Base | |
belongs_to :issue | |
belongs_to :title | |
attr_accessible :issue_id, :title_id | |
end | |
class Person < ActiveRecord::Base | |
has_many :person_roles | |
has_many :roles, :through => :person_roles | |
has_many :issues, :through => :person_roles | |
attr_accessible :name | |
end | |
class PersonRole < ActiveRecord::Base | |
belongs_to :issue | |
belongs_to :role | |
belongs_to :person | |
attr_accessible :issue_id, :name, :person_id, :role_id | |
end | |
class Publisher < ActiveRecord::Base | |
has_many :issues | |
attr_accessible :name | |
end | |
class Role < ActiveRecord::Base | |
has_many :person_roles | |
has_many :people, :through => :person_roles | |
has_many :issues, :through => :person_roles | |
attr_accessible :name | |
end | |
class Title < ActiveRecord::Base | |
has_many :issues_titles | |
has_many :issues, :through => :issues_titles | |
has_many :publishers, :through => :issues | |
attr_accessible :name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment