Guest User

Untitled

a guest
Sep 28th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # SystemStackError: stack level too deep
  2. # from /Users/johnslivka/.rvm/rubies/ruby-1.9.2-#p290/lib/ruby/1.9.1/irb/workspace.rb:80
  3. #Maybe IRB bug!!
  4.  
  5. class User
  6. include DataMapper::Resource
  7.  
  8. property :id, Serial
  9. property :email, String, :length => 255#, :required => true
  10.  
  11. has n, :relationships
  12. has n, :followers, :through => :relationships, :model => 'User',
  13. :child_key => [:user_id]
  14. has n, :follows, :through => :relationships, :model => 'User',
  15. :via => :user, :child_key => [:follower_id]
  16. end
  17.  
  18. class Relationship
  19. include DataMapper::Resource
  20.  
  21. property :user_id, Integer, :key => true
  22. property :follower_id, Integer, :key => true
  23.  
  24. belongs_to :user, :child_key => [:user_id]
  25. belongs_to :follower, :model => 'User', :child_key => [:follower_id]
  26. end
Add Comment
Please, Sign In to add comment