On Aug 24, 4:14 pm, Ar Chron <[email protected]> wrote: > Bob Smith wrote: > > > I have 2 name fields called name and sname. What I am trying to do is > > show both names in the index page at the beginning of > > the app. They need to be combined as a list which is then put in > > alphabetical order and given to the index page to be displayed with > > edit links for each item. > > > Bob > > controller: > > def index > # get ordered households > @households = Household.find(:all, :order => 'sname, name') > end > > index view: > <table> > <% @households.each do |hh| %> > <tr> > <td><%= link_to 'Edit Me!', edit_household_path(hh) %></td> > <td><%= link_to 'Old school link', :controller => 'households', > :action => 'edit', :id => hh.id %></td> > <td><%= h(hh.sname)+', '+h(hh.name) %></td> > </tr> > <% end %> > </table> > > or if you simply want a list of links: > > <table> > <% @households.each do |hh| %> > <tr> > <td><%= link_to h(hh.sname)+', '+h(hh.name), > edit_household_path(hh) %></td> > </tr> > <% end %> > </table> > > or something like that... > -- > Posted viahttp://www.ruby-forum.com/.
The problem I'm having is in combining these two name lists into one list, then putting it in alphabetical order. Name is for head of household, and sname is for a second person, either a wife or husband. These are two fields in the same record. Combining the lists and putting them in alphabetical order will show a full list to match whoever comes for the food. This program is for a local foodbank. Thanks Bob -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

