Guest User

Untitled

a guest
Jul 12th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. require 'rubygems'
  2. require 'dm-core'
  3. require 'dm-constraints'
  4.  
  5. DataMapper::Logger.new(STDOUT, :debug)
  6. DataMapper.setup(:default, 'mysql://localhost/dm_core_test')
  7.  
  8. class Comment
  9. include DataMapper::Resource
  10.  
  11. property :id, Serial
  12. property :name, String
  13.  
  14. has n, :categories, :through => Resource, :constraint => :destroy!
  15.  
  16. end
  17.  
  18. class Category
  19. include DataMapper::Resource
  20.  
  21. property :id, Serial
  22. property :name, String
  23.  
  24. has n, :comments, :through => Resource, :constraint => :destroy!
  25.  
  26. end
  27.  
  28. DataMapper.auto_migrate!
  29. DataMapper.auto_migrate!
Add Comment
Please, Sign In to add comment