# Too many columns for list.rhtml to display on one page

**URL:** <https://www.ruby-forum.com/t/too-many-columns-for-list-rhtml-to-display-on-one-page/51410>\
**Category:** Rails\
**Created:** [December 30, 2005, 11:27pm UTC](https://www.ruby-forum.com/t/too-many-columns-for-list-rhtml-to-display-on-one-page/51410 "2005-12-30T23:27:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [December 30, 2005, 11:27pm UTC](https://www.ruby-forum.com/t/too-many-columns-for-list-rhtml-to-display-on-one-page/51410/1 "2005-12-30T23:27:24Z")

</div>

I’ve gone once through the Agile book and am now attempting my own rails  
app. I’ve created a table named ‘volunteers’ with over 15 columns. The  
problem is the default list.rhtml that is created with the scaffold,  
shows all the columns. I only want to show 4 of them with the list  
view.

Where would I start to only return a handfull of columns to the screen?  
I think I do it in the view (list.rhtml - excerpted below). Does anyone  
have an example that only prints out a subset of the columns in a table?

…

# Listing volunteers
 \<% for column in Volunteer.content\_columns %\> \<% end %\> ............

| \<%= column.human\_name %\> |
| --- |

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [December 30, 2005, 11:34pm UTC](https://www.ruby-forum.com/t/too-many-columns-for-list-rhtml-to-display-on-one-page/51410/2 "2005-12-30T23:34:12Z")

</div>

Sean C. wrote:

> …
> 
> # Listing volunteers
> \<% for column in Volunteer.content\_columns %\> \<% end %\> ............
> 
> You can edit your model and list the columns you want to display  
> (anywhere after the class line):
> 
> def self.list\_columns  
> self.columns\_hash.values\_at(“name”,“phone”,“address”)  
> end
> 
> (edit name, phone, address to be the columns you want)
> 
> Then, tweak your list.rhtml view:
> 
> \<% for column in Volunteer.list\_columns %\>
> 
>   
> \<% end %\>
> 
> Hope this helps.
> 
> Phil
> 
> | \<%= column.human\_name %\> |
> | --- |
> | \<%= column.human\_name %\> |
> | --- |

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [December 30, 2005, 11:46pm UTC](https://www.ruby-forum.com/t/too-many-columns-for-list-rhtml-to-display-on-one-page/51410/3 "2005-12-30T23:46:16Z")

</div>

Sean C. wrote:

> …
> 
> # Listing volunteers
> \<% for column in Volunteer.content\_columns %\> \<% end %\> ............
> 
> Something like:
> 
> \<% my\_content\_columns = %w{foo bar qux}.collect {|colname|  
> Volunteer.columns\_hash[colname]} %\>
> 
> | \<%= column.human\_name %\> |
> | --- |
> 
> \<% for column in my\_content\_columns %\> \<% end %\> \<% for volunteer in @volunteers %\> \<% for column in my\_content\_columns %\> \<% end %\> \<% end %\>
> 
> | \<%= column.human\_name %\> |
> | --- |
> | \<%= volunteer.send(column.name) %\> |
