Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: None  |  size: 0.77 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. multicolumn primary keys in rails
  2. authors
  3.   author_name,
  4.   author_letter,
  5.   author_nr1,
  6.   author_nr2
  7.   ...
  8.  
  9. titles
  10.   titel_nr,
  11.   titel_name,
  12.   ...
  13.  
  14. author_titles
  15.   titel_nr,
  16.   author_letter,
  17.   author_nr1,
  18.   author_nr2
  19.        
  20. add_index :users, [:merchant_id, :email], :unique => true
  21.     add_index :users, [:merchant_id, :login], :unique => true
  22.        
  23. validates_uniqueness_of :email,    :scope => :merchant_id
  24.   validates_uniqueness_of :login,    :scope => :merchant_id
  25.        
  26. class Author
  27.   set_primary_keys :author_letter, :author_nr1, :author_nr2
  28.   has_many :titles, :through => :author_title
  29. end
  30.  
  31. class Title
  32.   set_primary_key :title_nr
  33. end
  34.  
  35. class AuthorTitle
  36.   belongs_to :title, :foreign_key => :title_nr
  37.   belongs_to :authori, :foreign_key => [:author_letter, :author_nr1, :author_nr2]
  38. end