繼text_method是從API爲collection_select方法的摘錄:的Rails:collection_select
collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})
我的收藏是字符串數組。在text_method我想輸出修改後的字符串gsub(一些正則表達式的東西)。做這件事的最好方法是什麼?我可以考慮重新打開String類併爲text_method實現一些東西,但是如果想象它不是很好的方法。
謝謝。
這是做什麼/它從哪裏來的?數組已經有[select方法](http://rubydoc.info/stdlib/core/1.9.3/Array#select-instance_method)。 –
它來自表單選擇框值。因此,如果我將使用f.select而不是f.collection_select,我會在概念上面對同樣的問題,對嗎? – alexs333