On Aug 23, 4:06 pm, Colin Law <clan...@googlemail.com> wrote: > On 23 August 2010 20:20, Bob Smith <bsm...@gmail.com> wrote: > When I suggested not top posting, I suggested inserting your post in > the previous post in order that it appears after the question it is > answering. Not just sticking the reply down the bottom. > > > 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. > > So which part is giving the problem? Fetching the records from the > database in the right order (in the controller), making the records > available to the view, showing the names on the view or showing the > edit links? > > [This would be a good place to insert your reply] > > Colin
Bob, what Colin (and others) are trying to understand is what you're actually trying to do. When you say that you have 2 name fileds (name and sname) do you mean that you have a first name and a surname, each in a Household record (i.e., corresponding, for example, to the head of the household), or do you mean that you have another model (i.e., Person) in which you have fields for name, sname, and household_id (thereby relating the Person record to the Household to which the person belongs, with associated relationships in the models)? As you indicated that you want to display the id of the "name or sname" the inference which I draw is that they will be different, thereby implying that your two name fields are in a model different from the Household model (as they would otherwise both have the same id, corresponding to the id of the Household record). If both name and sname are fields in the same (Person) record (and related to a particular Household record), then concatination can be done in your view, model, or a helper, with the better practice being in the model or helper. Note that you probably do not want hh.name + hh.sname (as suggested above) as that would look strange. You probably would want either hh.sname + ', ' + hh.name or hh.name + ' ' + hh.sname instead. Until you ask a clearly defined question, it is impossible to guess what you want or to provide you with the appropriate guidance. Sandy -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.