I’m using MongoDB and Mongo Mapper and need to find an embedded document inside of an array. There has to be a simpler way to do this than the way I got working which is:
@obj.subitems.each do |c|
if (c.slug.eql? params[:id])
@subitem = c # this is the variable i need
end
end
Thanks
http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-detect