所以我有这个数据结构:
+[#<Folder id: 1,name: "mollitia",parent_id: nil,user_id: 1,created_at: "2014-06-27 16:00:59",updated_at: "2014-06-27 16:00:59">,+ #<Folder id: 2,name: "porro",parent_id: 1,+ #<Folder id: 3,name: "omnis",parent_id: 2,updated_at: "2014-06-27 16:00:59">]
由self.ancestors返回
我可以采摘它的名字吗?
def pwd self.ancestors.pluck(:name) end
以上结果
undefined method `pluck' for #<Array:0x007ff4da780290>
更新
令人敬畏的结构打印:
[ [0] #<Folder:0x007fd2946a5f18> { :id => 3,:name => "blanditiis",:parent_id => 2,:user_id => 1,:created_at => Fri,27 Jun 2014 18:04:02 UTC +00:00,:updated_at => Fri,27 Jun 2014 18:04:02 UTC +00:00 },[1] #<Folder:0x007fd2946ad1c8> { :id => 2,:name => "neque",:parent_id => 1,[2] #<Folder:0x007fd2946b80c8> { :id => 1,:name => "ut",:parent_id => nil,27 Jun 2014 18:04:02 UTC +00:00 } ]