In my database I have a Films table with three columns: id, title, added_at.
In the controller for the list action I just do:
In the simplified list.rhtml view I'm trying to get at a list of attributes (e.g., columns) to print a table with:
@films.class is an Array
What I did to make that work is:
I don't understand why the this works and the one before it doesn't.
Output when these are together is:
Could a Rails user point out the error of my ways? Why does
print #<Film:0x4ae37610> ?
In the controller for the list action I just do:
Code:
def list
@films = Film.find(:all)
end
In the simplified list.rhtml view I'm trying to get at a list of attributes (e.g., columns) to print a table with:
Code:
<%= h @films.each { |k| k.inspect } %>
@films.class is an Array
What I did to make that work is:
Code:
<% @films.each { |f| %>
<%= h f.inspect %>
<% } %>
I don't understand why the this works and the one before it doesn't.
Output when these are together is:
Code:
#<Film:0x4ae37610>
#<Film:0x4ae37610 @attributes={"title"=>"Ocean's 11", "id"=>"1", "added_at"=>nil}>
Could a Rails user point out the error of my ways? Why does
Code:
<%= h @films.each { |k| k.inspect } %>