rat*_*tan 10 ruby ruby-on-rails
我希望有一个下降值,包含值10%20%30%,所以直到100.
在红宝石中它可以通过
(10..100).step(10) { |i| p i }
Run Code Online (Sandbox Code Playgroud)
我该如何将其转换为选择标签?
我试过了:
<%=p.select :thc, options_for_select((10..100).step(10) {|s| ["#{s}%", s]})%>
Run Code Online (Sandbox Code Playgroud)
但这是打印 10 11 12 13....100
Jim*_*nke 15
你几乎拥有它:
<%=p.select :thc, options_for_select((10..100).step(10).to_a.map{|s| ["#{s}%", s]})%>
Run Code Online (Sandbox Code Playgroud)