开发者

Rails3 display HASH value

Im trying to use the Ancestry gem. How can I display a value from a HASH to screen from a HASH that looks like this:

{ #<TreeNode id: 100018, name: "Stinky", ancestry: nil>
    { #<TreeNode id: 100019, name: "Crunchy", ancestry: "100018">
       { #<TreeNode id: 100020, name开发者_C百科: "Squeeky", ancestry: "100018/100019">
       {}
       }
    }
}

Thank you...


If you are doing this for debugging purposes, in your view file, you can use the 'debug' helper method

# app/views/pages/index.html.erb

<%= debug(@page) %>

assuming that hash is in the @page variable.

EDIT

I've never used the ancestry gem before, but reading its github page ("Navigating your tree") maybe you can do this in your view

<%= @record.parent.name %>
<% for descendant in @record.descendants %>
  <%= descendant.name %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜