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 %> <th><%= column.human_name %></th> <% end %> </tr> <% for person in @people %> <tr> <% for column in Person.content_columns %> <td><%=h person.send(column.name) %></td> <% end %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jose Pepe wrote:> 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 %> > <th><%= column.human_name %></th> > <% end %> > </tr> > > <% for person in @people %> > <tr> > <% for column in Person.content_columns %> > <td><%=h person.send(column.name) %></td> > <% end %> >Jose, you can overide content_columns method in Person model. best regards, Bojan Mihelac -- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
How? coul you please give me an example thanks Bojan Mihelac wrote:> Jose Pepe wrote: >> >> <% for person in @people %> >> <tr> >> <% for column in Person.content_columns %> >> <td><%=h person.send(column.name) %></td> >> <% end %> >> > Jose, you can overide content_columns method in Person model. > > > best regards, > Bojan Mihelac > > -- > Bojan Mihelac > Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com > -> tools, scripts, tricks from our code lab: http://source.mihelac.org-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
here is a way to do it: http://www.height1percent.com/articles/2006/03/07/ajaxscaffold-lessons-customizing-the-display-columns-and-using-the-scaffolds-as-components -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
In the folowing example I only show two columns first Name and Last Name <h1>Listing people</h1> <table> <tr> <!-- <% for column in Person.content_columns %> <th><%= column.human_name %></th> <% end %> --> <th>First Name</th> <th>Last Name</th> </tr> <% for person in @people %> <tr> <td><%=h person.FirstName %></td> <td><%=h person.LastName %></td> </tr> <% end %> <!-- <% for column in Person.content_columns %> <td><%=h person.send(column.name) %></td> <% 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 %></td> </tr> <% end %> </table> <%= 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 %> <br /> <%= link_to ''New person'', :action => ''new'' %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
for example def content_column @content_columns ||= columns.reject { |c| c.name != ''some_column_name''} end best, Bojan Mihelac Jose Pepe wrote:> How? coul you please give me an example > > thanks > > > Bojan Mihelac wrote: >> Jose Pepe wrote: >>> <% for person in @people %> >>> <tr> >>> <% for column in Person.content_columns %> >>> <td><%=h person.send(column.name) %></td> >>> <% end %> >>> >> Jose, you can overide content_columns method in Person model. >> >> >> best regards, >> Bojan Mihelac >> >> -- >> Bojan Mihelac >> Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com >> -> tools, scripts, tricks from our code lab: http://source.mihelac.org > >-- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---