Rails join a list of strings with commas and “and” before the last

后端 未结 1 808
我在风中等你
我在风中等你 2021-02-06 21:27

Is there a standard rails helper that converts an array of strings like [\"apple\", \"banana\", \"pear\"] into \"apple, banana, and pear\" for insertin

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-06 22:11

    Yeah to_sentence ought to work nicely.

    http://apidock.com/rails/Array/to_sentence

    0 讨论(0)
提交回复
热议问题