In the Rails docs , select
帮助器列出的前两个选项是 :include_blank
和 :prompt
。我刚刚意识到我在代码中同时使用了这两种方法,但它们似乎可以互换。谁能解释其中的区别吗?通过阅读文档,我并不清楚。
最佳答案
主要区别是:
include_blank: true
将呈现一个空白选项,但是
prompt: true
将执行
I18n.translate('helpers.select.prompt', :default => 'Please select')
关于ruby-on-rails - :include_blank and :prompt in the Rails select helper? 和有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11302728/