The other day I was reviewing a collegue’s code, who shall remain nameless to protect their innocense, and came across this lil gem:
1 Tags 2 3 4 , 5 6
Now while it does work, it’s definately not the Ruby way, as we can rewrite it more elegantly like:
1 Tags 2 3 4
The ‘tags’ association here returns an array, so we can just call the join method on it. This will delimit the array contents with whatever string we like, in this case just a comma. Ah much better and concise.