Created
April 18, 2012 20:03
-
-
Save anonymous/2416154 to your computer and use it in GitHub Desktop.
stack overflow in datamapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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