Created
November 28, 2016 18:08
-
-
Save kyanny/42d961b252a5f1aca797f8482d959ca5 to your computer and use it in GitHub Desktop.
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
gem 'activemodel', '4.2.7.1' | |
require 'active_model' | |
require 'mongo_mapper' | |
require 'byebug' | |
require 'logger' | |
logger = Logger.new(STDOUT) | |
logger.level = :info | |
MongoMapper.setup( | |
{ | |
'development' => { | |
'host' => '127.0.0.1', | |
'port' => 27017, | |
'database' => 'testing', | |
} | |
}, | |
'development', | |
logger: logger | |
) | |
class User | |
include MongoMapper::Document | |
one :membership | |
end | |
class Membership | |
include MongoMapper::Document | |
belongs_to :user | |
end | |
class WrapUser < User | |
one :membership, foreign_key: :user_id | |
end | |
wrap_user = WrapUser.create! | |
membership = Membership.create!(user: wrap_user) | |
wrap_user.reload | |
MongoMapper.connection.logger.level = :debug | |
p wrap_user.membership | |
Author
kyanny
commented
Nov 28, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment