Skip to content

Instantly share code, notes, and snippets.

@deivid-rodriguez
Created October 29, 2014 17:29
Show Gist options
  • Save deivid-rodriguez/869c5468cedd35afd4bf to your computer and use it in GitHub Desktop.
Save deivid-rodriguez/869c5468cedd35afd4bf to your computer and use it in GitHub Desktop.
model Token
include Mongoid::Document
field :user_id
end
model User
include Mongoid::Document
has_many :tokens
end
# In the Rails console this works...
$ Token.where(user_id: Token.first.user_id).first
#<Token _id: ...>
# I feel tempted to add `belongs_to :user` to the token model, but after doing so...
$ Token.where(user_id: Token.first.user_id).first
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment