我有一個複選框Ruby on Rails的複選框,不保存數據
<%= f.check_box :anonymous %>
而我的表有一欄anonymous
這是真的還是假的。在生成的HTML
代碼:
<input name="comment[anonymous]" type="hidden" value="0" />
<input id="comment_anonymous" name="comment[anonymous]" type="checkbox" value="1" />
現在,由於某種原因,當我添加如果我的匿名複選框被選中或不..它不是在數據庫中更改數據它不保存數據。所有其它領域得到除匿名保存外。
可能是什麼問題?
你能展示更多的視圖代碼嗎?就像'f.check_box'周圍的'form_for'一樣? – lurker
'<%= form_for(comment,:url =>(defined?(submit_url)?submit_url:[commentable,「comments」]),:method =>:post,:id =>「comment-form」,:class =>「form-horizontal」)do | f | %>' – user1736479