Ruby on rails 向select标记添加默认空值
我目前有以下代码行:Ruby on rails 向select标记添加默认空值,ruby-on-rails,select,haml,Ruby On Rails,Select,Haml,我目前有以下代码行: =select_tag :resource_id, options_for_select( Resource.find(:all, :conditions => "resourcetype = 'data-sheets' && category = 'Data Centres'", :order => "title ASC").map{|l| [l.title, l.id] }, @dc.try(:resource_id) ) 它的工作原理是显
=select_tag :resource_id, options_for_select( Resource.find(:all, :conditions => "resourcetype = 'data-sheets' && category = 'Data Centres'", :order => "title ASC").map{|l| [l.title, l.id] }, @dc.try(:resource_id) )
它的工作原理是显示从数据库中提取的列表,并选择字段的当前值,但我需要在列表顶部添加一个没有值的“请选择”选项 有一个“空白”选项
此外,您可以使用提示符
设置该文本的值还有一个“blank”选项
此外,您还可以使用提示符
设置该文本的值
:include_blank => true