Rails collection_select 使用如何编辑下拉框选项

kun · April 11, 2022 · Last by kun replied at April 12, 2022 · 303 hits
<%= f.collection_select :leixing , { "program" => "编程题", "select" => "选择题" }, :to_s, :to_s %>

显示结果 返回得值也是 ["select", "选择题"] 或 ["program", "编程题"] 我只想下拉框中显示和返回值只有 "编程题"和"选择题",尝试过下面的写法

<%= f.collection_select :leixing , { "编程题", "选择题" }, :to_s %>

意料中出现了错误,这样应该是不满足集合条件了吗? 在 guides.rubyonrails.org 介绍的用法和我这个不太一样,望大佬们帮忙解答

Reply to illusove

感谢您的回答 我还没没用明白这个教程,我已经用别的方法解决我这个问题了

kun closed this topic. 12 Apr 10:55
You need to Sign in before reply, if you don't have an account, please Sign up first.