Too many columns for list.rhtml to display

Hi all

in the list.rhtml generated by the scaffoldhow can I select the columns
I want to display. the code by default shows everything

% for column in Person.content_columns %>

<%= column.human_name %>
<% end %>

<% for person in @people %>

<% for column in Person.content_columns %> <%=h person.send(column.name) %> <% end %>

Jose P. wrote:

<% for person in @people %>

<% for column in Person.content_columns %> <%=h person.send(column.name) %> <% end %>

Jose, you can overide content_columns method in Person model.

best regards,
Bojan M.


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
→ tools, scripts, tricks from our code lab: http://source.mihelac.org

How? coul you please give me an example

thanks

Bojan M. wrote:

Jose P. wrote:

<% for person in @people %>

<% for column in Person.content_columns %> <%=h person.send(column.name) %> <% end %>

Jose, you can overide content_columns method in Person model.

best regards,
Bojan M.


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
→ tools, scripts, tricks from our code lab: http://source.mihelac.org

In the folowing example I only show two columns first Name and Last Name

Listing people

<% for person in @people %>

<% end %>
<td><%= link_to 'Show', :action => 'show', :id => person %></td>
<td><%= link_to 'Edit', :action => 'edit', :id => person %></td>
<td><%= link_to 'Destroy', { :action => 'destroy', :id => person }, 

:confirm => ‘Are you sure?’, :post => true %>

<% end %>
First Name Last Name
<%=h person.FirstName %> <%=h person.LastName %>

<%= link_to ‘Previous page’, { :page => @person_pages.current.previous }
if @person_pages.current.previous %>
<%= link_to ‘Next page’, { :page => @person_pages.current.next } if
@person_pages.current.next %>


<%= link_to ‘New person’, :action => ‘new’ %>

here is a way to do it:

for example

def content_column
@content_columns ||= columns.reject { |c| c.name !=
‘some_column_name’}
end

best,
Bojan M.

Jose P. wrote:

<td><%=h person.send(column.name) %></td>

Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
→ tools, scripts, tricks from our code lab: http://source.mihelac.org


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
→ tools, scripts, tricks from our code lab: http://source.mihelac.org