当然有一种聪明的方式来写这个:
%select{:name => "status", :id => "status"}
- if params[:status].include? "Active"
%option Either
%option Inactive
%option{:selected => :selected} Active
- elsif params[:status].include? "Inactive"
%option Either
%option{:selected => :selected} Inactive
%option Active
- else
%option{:selected => :selected} Either
%option Inactive
%option Active
思想?
答案 0 :(得分:0)
答案结果是:
%select{:name => "status", :id => "status"}
= options_for_select(["Either", "Active", "Inactive"], params[:status])