On Aug 23, 3:24 am, Colin Law <[email protected]> wrote:
> On 22 August 2010 23:04, Bob Smith <[email protected]> wrote:
>
> Once again, please do not top post.  Insert your reply a appropriate
> points in the previous message.  Thanks
>
> > What I need returned is a list of the names in the fields name and
> > sname put together in alphabetical order with their ids
> > so I can make this list into an index screen with edit links. I assume
> > the id would be Household.id, just looking for a way to combine
> > two name fields for the index page.
>
> I think I am slowly managing to get some grasp of what you are trying
> to achieve, though it is proving very difficult to get information
> from you.
>
> Is it right that you want a view showing a list of households where
> for each household you show the name which is a concatenation of two
> fields from the household object?  If so then you can do something
> like
>
> <% @households.each do |household| %>
> <%= "#{household.name1} #{household.name2}" %>
> <% end %>
>
> However it would be better to provide a method oh Household that
> returns the combined name so you can use
> <%= household.combined_name %>
>
> Colin
>
>
>
> >                Bob
>
> > On Aug 21, 8:19 am, Colin Law <[email protected]> wrote:
> >> On 21 August 2010 08:40, Bob Smith <[email protected]> wrote:
>
> >> > All I need is a list of names and their id field so I can setup links
> >> > to edit them from the view. The problem is that there are two name
> >> > lists. I need to combine them and have either rails or SQL order them
> >> > alphabetically.
>
> >> Please don't top post, it makes it difficult to follow the thread.
> >> What do you mean a list of names and their id fields?  You said that
> >> the names are fields in your model, so they do not have id's of their
> >> own.  I asked that question last time and you have not answered it.
>
> >> Colin
>
> >> > On Aug 20, 4:51 am, Colin Law <[email protected]> wrote:
> >> >> On 20 August 2010 06:41, Bob Smith <[email protected]> wrote:
>
> >> >> > My model has twofieldsthat I want in a customerlistfor an index
> >> >> > page. They are name and second_name. I need a way to combine them in a
> >> >> > collection with their id numbers so the Edit links will work. Sounds
> >> >> > like SQL, but I'm not sure.
>
> >> >> I don't understand what you mean by 'their id numbers'.  The household
> >> >> record will have an id but the individualfieldsdo not, they just
> >> >> have the text of the name and second_name.  Perhaps you are talking
> >> >> about relationships to other models rather thanfieldsin the model?
> >> >> If so then we need to know the relationships.
>
> >> >> Colin
>
> >> >> > maybe something like:
> >> >> > SELECT name, id FROM households and SELECT second_name, id FROM
> >> >> > households
>
> >> >> > just not sure how to make ONE statement from these two including
> >> >> > both...
>
> >> >> > 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 
> >> >> > athttp://groups.google.com/group/rubyonrails-talk?hl=en.
>
> >> > --
> >> > 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 
> >> > athttp://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > --
> > 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 
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en.


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

-- 
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.

Reply via email to