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 %>
<% end %>
<% for person in @people %>
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 %>
<% for person in @people %>
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
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs