What's the difference between :include_blank and :prompt in the Rails select helper?

无人久伴 提交于 2019-12-21 12:21:10

问题


In the Rails docs, the first two listed options for the select helper are :include_blank and :prompt. I've just realized that I'm using both in my code, but they seem to be interchangeable. Can anyone explain the difference? It's not clear to me from reading the docs.


回答1:


Main difference is:

include_blank: true

will render a blank option but

prompt: true

will execute

I18n.translate('helpers.select.prompt', :default => 'Please select')


来源:https://stackoverflow.com/questions/11302728/whats-the-difference-between-include-blank-and-prompt-in-the-rails-select-hel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!