Please bear in mind that I’m totally new to Rails when answering this.My question is as follow:
I have an Array that is result of a .find query. This Array is passed to view and each item is shown. BUT, before passing it I need to add info to each of the Array elements.
If each element was an Array I could use <<, if it was a hash I could use .merge, but since I have no idea whatsoever of what it is I don’t know how I can add the info…..
Hope you can help me!
Ok, your comment clears it up a bit. When you do
User.find(n)you get back auserobject. If you do something likeUser.find(1, 2, 3)then you get an array ofuserobjects. So adding to this dynamically is probably not an ideal solution.But here’s one hacky way to do it
This will convert your
userobject to an array and then append a value to it. Not recommended but it will do what you’re asking for.