Guest User

Untitled

a guest
May 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 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. property :created_at, DateTime
  10.  
  11. belongs_to :matches
  12. has n, :keywords, :through => :matches
  13. end
  14.  
  15. ## keyword.rb
  16.  
  17. class Keyword
  18. include DataMapper::Resource
  19.  
  20. property :id, Integer, :serial => true
  21. property :keyword, String, :nullable => false
  22.  
  23. belongs_to :matches
  24. has n, :articles, :through => :matches
  25.  
  26. end
  27.  
  28. ## matches.rb
  29.  
  30. class Match
  31. include DataMapper::Resource
  32.  
  33. property :id, Integer, :serial => true
  34. has 1, :article
  35. has 1, :keyword
  36. property :weight, Integer
  37.  
  38. end
Add Comment
Please, Sign In to add comment