Thursday 15 May 2014

ruby on rails - Parent fields are all nil when accessed by child (embedded 1-n) -


I have a 1-N relationship defined:

  class user field: Email, type: string embeds_memory: paper and class paper embedded_in: user end   

If I try to use the original field (user) from the original (paper):

  User.all.map (: papers) .flatten.first.user.email   

Then I get zero: ( < P> Access like this work though ok:

  User.all .first.papers.first.user.email    

A misspelling report on this comment To call a method on a map, you need to use & amp; before your symbol.

Try: < P> User.all.map (& amp;: papers). Flatten.first.user.email

No comments:

Post a Comment