comments = story.comments.collect {|comment| comment.body }
assuming that Comment objects respond to a ''body'' method which
contains the meat and potatoes of the comment.
Mike
On 3/8/08, dino d. <dinodorroco-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:>
> Hi-
>
> Simple question, just can''t find a reference. I have an array of
> records via a habtm, and simply want to harvest all of the values of
> one field into an array of strings. Example:
>
> story = Story.find(:first)
> comments = story.comments.XXXX # should equal ["great story",
"i
> agree", ...]
>
> I suspect there is a simple built in method.
>
> Thanks for any help,
> Dino
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---