在控制檯中,我的查詢工作只是罰款:RoR3 HABTM複選框不保存
u = Radcheck.get(23)
g = Group.get(16)
@relationship = u.radgroups << g
和一個保存寫入到數據庫。
當我在我的導軌視圖中嘗試這樣做時,它不會保存。
<%= check_box_tag "radcheck[groupnames][]", group.id, @radcheck.radgroups.include?(group) %>
進出口使用DataMapper的,並有radcheck模型設置是這樣的:
has n, :radusergroup, :child_key => [:username], :parent_key => [:username]
has n, :radgroups, :through => :radusergroup, :model => 'Group'
我radcheck表包含列的用戶名和組名
有什麼建議?
- 更新 -
而且下面來回答,我已經添加了一個ID,radusergroup表(我的連接表)。這目前看起來是這樣的:
+-------------+---------------------------+----------+----+
| username | groupname | priority | id |
+-------------+---------------------------+----------+----+
| hcTTm | 3600 | 1 | 1 |
| FpKS4 | 3600 | 1 | 2 |
| jenny | Disabled-Users | 1 | 3 |
| silver | silver | 1 | 4 |
| shushQb | 30-minutes | 0 | 5 |
| jenny | silver | 1 | 6 |
+-------------+---------------------------+----------+----+
現在這是推動我分心
我有完全在我的模型正確的信息,只能假定它的保存是個問題?
通過刪除一些從未得到答案的問題(而不是11月問題),建議您接受%(問題的第2頁)。 –
謝謝我會這樣做。不太清楚爲什麼會影響這個問題呢? –