rails select helper

<%=select_tag('site_id',options_for_select(@sites.collect{|s| [s.name,s.id]}.insert(0,["所有",0])) )%>

<%=select_tag('server_room_id',options_from_collection_for_select(ServerRoom.find_all_have_site_server_rooms,:id,:room))%>

<%=select('site','id',Site.find(:all).collect{|s| [s.name,s.id]}.insert(0,["所有",0]))%>这种在controller处理时格式params[:site][:id]

<%=select('site','isp_id',Isp.find(:all).collect{|i| [i.name,i.id]},{:selected=>@site.isp_id})%>选中某个值

你可能感兴趣的:(rails select helper)