model
私は好きです、
def question_hash_string
@question_hash_string || '{}'
end
def question_hash
ActiveSupport::JSON.decode question_hash_string
end
でJavascript
、
var question_hash_element = document.getElementById('enr_rds_batch_update_question_hash_string');
var question_hash = JSON.parse(question_hash_element.value);
question_hash[batch_question_id] = (batch_answer_id || batch_rdsap_answer || batch_answer_checkbox);
question_hash_element.value = JSON.stringify(question_hash);
それは次のような値を与えるでしょう"{"16":"3","28":false}"
次のような答えで別の価値を追加したいのですが、
question_hash[batch_question_id] = ((batch_answer_id || batch_rdsap_answer || batch_answer_checkbox) && (build_id));
"{"16":"3","28":false:"2", "3":"55":"54"}"
等々。':'を使用して既存のレコードに別の列を追加する必要があります。