Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不知道该怎么做。我只想为一个字段而不是文本字段提供一个下拉列表框。我想为配置文件模型的国家列显示一个下拉列表...任何帮助都会很明显
在模型中创建一个常量:
COUNTRIES = ["Democratic", "Republic"]
然后,在视图中,在表单中创建一个下拉列表并使用常量来填充它。
像这样的东西:
= f.select :country, ModelName::COUNTRIES, { prompt: "Select Country" }