Querying association with Mongo_mapper with embedded document
I have a Users model with embedded Friend model. When a user registers, it saves their info, and then inserts they friend data.
class User
include MongoMapper::Document
key :first_name, String
key :last_name, String
key :email, String
key :fb_user_id, String
key :token, String
timestamps!
class Friend
include MongoMapper::EmbeddedDocument
key :name, String
key :fb_user_id, String
I've got the data in, but I'm having trouble querying the friend data that's inside the User object.
User.where("friends.i开发者_StackOverflowd" => "4e03e796516d9b0f9c0001ab")
I can't use what's given back to get anything??
=> #<Plucky::Query friends.id: "4e03e796516d9b0f9c0001ab", transformer: #<Proc:0x00000102b0a830@/Users/^^^^^^^/.rvm/gems/ruby-1.9.2-p180/gems/mongo_mapper-0.9.1/lib/mongo_mapper/plugins/querying.rb:79 (lambda)>>
What do I need to do to properly query the "name" and "fb_user_id" fields?
精彩评论