Skip to content

Instantly share code, notes, and snippets.

Created April 18, 2012 20:03
Show Gist options
  • Save anonymous/2416154 to your computer and use it in GitHub Desktop.
Save anonymous/2416154 to your computer and use it in GitHub Desktop.
stack overflow in datamapper
# SystemStackError: stack level too deep
# from /Users/name/.rvm/rubies/ruby-1.9.2-#p290/lib/ruby/1.9.1/irb/workspace.rb:80
#Maybe IRB bug!!
class User
include DataMapper::Resource
property :id, Serial
property :email, String, :length => 255#, :required => true
has n, :relationships
has n, :followers, :through => :relationships, :model => 'User',
:child_key => [:user_id]
has n, :follows, :through => :relationships, :model => 'User',
:via => :user, :child_key => [:follower_id]
end
class Relationship
include DataMapper::Resource
property :user_id, Integer, :key => true
property :follower_id, Integer, :key => true
belongs_to :user, :child_key => [:user_id]
belongs_to :follower, :model => 'User', :child_key => [:follower_id]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment