class Account
has_many :complete_posts, :class_name => "Post", :inverse_of => :complete_user
class Post
belongs_to :complete_user, :class_name => "Account", :inverse_of => :complete_posts
为什么我保存后,用 mongohub 查看 mongodb 在 Post 能查看到 complete_user_id 但在 Account 却看不到 complete_post_ids
代码里面能还能打印出来
@post.complete_user.complete_post_ids
=> ["507e24e272eee588f5000001",
"50642a30c3666e92b1000006",
"5064242272eee53b970000a2",
"506426b172eee53b970000a5",
"50641c4572eee53b97000043",
而且 self.complete_post_ids.include?(uid) 返回 true
return false if self.complete_post_ids.include?(uid)
128: self.push(:complete_post_ids,uid)
我之前没有保存过进去