Can't access model attributes via symbol

If I do a:

In controller:
@x = User.find(:all)

In view:
<% for rec in @x -%>
<h1><%= rec[:username] %></h1>
<% end -%>

It doesn't work. However, rec["username"] works.
If I look with the breakpointer, of course all keys
that ActiveRecord returns are strings. How can I access
by symbol instead? (It is important so I can stay DRY ;-))


would do it... just convert your symbol to a string...

Why not just:


or if you really feel the need to use a symbol:


but let the ActiveRecord attribute methods do their thing. :wink:


Rob Biedenharn