Rails: combining multiple find requests?

You have to initialize a = as an array before the searchid = 4 @a = while searchid! = -1 @a += A. Find(searchid) @b = B.

Find(searchid) searchid = @b. Parentid end You can combine them like: searchid = 4 @a = while searchid! = -1 @a += A.

Find(searchid) @a += B. Find(searchid) searchid = @a.last. Parentid end.

You have to initialize @a = as an array before the += . Searchid = 4 @a = while searchid! = -1 @a += A.

Find(searchid) @b = B. Find(searchid) searchid = @b. Parentid end You can combine them like: searchid = 4 @a = while searchid!

= -1 @a += A. Find(searchid) @a += B. Find(searchid) searchid = @a.last.

Parentid end.

Unfortunately that doesn't work. The error I get is: "TypeError: can't convert A into Array from (irb):8:in `+'" The 'A' being a model and the result of the 'find' being the result from a query to a database. I'm presuming you would need to create your own '+' function but I don't even know what format the find returns and I was hoping there was a more elegant solution.

– peppermonkey May 14 '10 at 17:22.

Got it to work (with help). Did the following: @a = with @a Also using @a. Compact!

To get rid of the null entries. Thanks for all the help :).

Yep, I just saw that you receive only one element. – dombesz May 16 '10 at 14:32 Also if you have to mix up, for example you will receive both single elements and arrays, you can also use the To have still an array of elements instead of array with arrays. – dombesz May 16 '10 at 14:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions