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 2 3 4 , 5 6 Tags
Now while it does work, it’s definately not the Ruby way, as we can rewrite it more elegantly like:
1 2 3 4 Tags
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.