Ahh that works, thanks!
I think I had the general idea but I think every time I tried

@a = []
I tried
@a += A.find_by_id(some_id)

while every time I tried
@a << A.find_by_id(some_id)
I never tried the
@a = []
....whoops,

thanks for all the help.
Plus never seen @a.compact!, helps a lot :)

btw, in general what I was looking for was a way to put the .find 
methods inside a loop and combine all the results into one result, 
everything else was just fluff.


Jeff Cohen wrote:
> On May 14, 2:09�pm, Hubert Yoshizaki <[email protected]> wrote:
>>
>> The output from a find looks something like:
>> => #<A id: 99, name: "A Name">
> 
> I'm not exactly sure I understand what you're trying to do, but I
> think you want something like this:
> 
> @a = []  # start with an empty array
> 
> @a << A.find_by_id(some_id)  # returns an object, or null if not
> found; push into array
> @a << B.find_by_id(some_id)  # returns an object, or null if not
> found; push into array
> 
> @a.compact!  # removes null entries from the array
> 
> Does that help?
> 
> Jeff
> 
> www.purpleworkshops.com

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