---
# System prepended metadata

title: '[Rails4][view]取出實體變數的所有鍵與值'
tags: [Rails4, view]

---

# [Rails4][view]取出實體變數的所有鍵與值

###### tags: `Rails4`,`view`

https://stackoverflow.com/questions/1289557/how-do-you-discover-model-attributes-in-rails

使用attributes方法
```htmlmixed
<% ttt= @instance_variable.attributes %>

<% ttt.each do |k,v| %>
    <div>
      <%=k%> : <%= v %>
    </div>
<% end %>
```
