Guest User

Untitled

a guest
May 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. ## article.rb
  2.  
  3. class Article
  4. include DataMapper::Resource
  5.  
  6. property :id, Integer, :serial => true
  7. property :url, String, :nullable => false, :length => 255, :format => /http:\/\//
  8. property :body, Text
  9.  
  10. has n, :matches
  11. has n, :keywords, :through => :matches
  12. end
  13.  
  14. ## keyword.rb
  15.  
  16. class Keyword
  17. include DataMapper::Resource
  18.  
  19. property :id, Integer, :serial => true
  20. property :keyword, String, :nullable => false
  21.  
  22. has n, :matches
  23. has n, :articles, :through => :matches
  24.  
  25. end
  26.  
  27. ## matches.rb
  28.  
  29. class Match
  30. include DataMapper::Resource
  31.  
  32. property :id, Integer, :serial => true
  33. belongs_to :article
  34. belongs_to :keyword
  35. property :weight, Integer
  36.  
  37. end
Add Comment
Please, Sign In to add comment