-2
在這裏,我正在構建數據庫驅動的單選按鈕。我想知道是否有方法可以讓我避免EVAL,看看檢查是真的還是假的!謝謝你,在軌道中構建單選按鈕時避免使用eval
指數控制器
columns = Model.column_names
觀HAML
- columns.each do |cols|
- check = "c[0].#{cols}==1? true : false" // checking value here
- negcheck = "c[0].#{cols}==0? true : false"// checking value here
- pluckid = "c[0].id"
- id = eval(pluckid)
%tbody
%td #{cols}
%td
= label_tag 'On'
= radio_button_tag("ABC",1,checked = eval(check), options = {})
= label_tag 'Off'
= radio_button_tag("xyz",0,checked = eval(negcheck), options = {})
什麼是'這裏C'? –