Reputation: 296
Why doesn't this work?
I have an array of Objects, one of the attributes is the db id. I can make the array like so.
qc_parts.map!{|a| a.id}
However when I want to just make it a string. With
qc_parts.map!{|a| a.id}.join(",")
I only get an array out. I've also tried .to_s
& .to_a
Any idea why this would be happening?
Upvotes: 0
Views: 1506
Reputation: 5609
qc_parts.map!{|a| a.id}.join(",")
will return a string, but it will not to put that value into the variable qc_parts
. To do that you have to do
qc_parts = qc_parts.map{|a| a.id}.join(",")
If I've misunderstood, and you actually are seeing the join
method return an array, then something strange is going on.
Upvotes: 2