Rails separate array items with comma inside partial

戏子无情 提交于 2019-12-01 12:08:54

Ruby's join method won't add the separator character if there is only a single element in the array.

You should be able to do the following for a list of any size:

@dvd.director.map(&:director).join(", ")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!