2010-03-24 79 views
2

我正在嘗試爲調查問題創建網格表單。Rails中的網格表格

  value1  value2 value3 

option 1  x 

option 2     x 

option 3  x 

網格中的每個單元格都是一個單選按鈕,並且一行中的單選按鈕屬於一個單選按鈕組。

我的模型:

class Question 
    # title 
    has_many :answers 
end 

class Answer 
    # name, position, atype(row/col) 
end 

對問題的樣本數據:

id title 
-- ------ 
1 Rate the following movies 

的樣本數據答案:

id question_id atype position name 
-- ----------- ----- -------- -------- 
1 1   row  1   God Father 
2 1   row  2   Star Wars 
3 1   row  3   Aliens 

4 1   col  1   Bad 
5 1   col  2   Average 
6 1   col  3   Good 

我竭力拿出來創建一個Rails方法這種形式。爲了使問題複雜化,用戶可以保存半完成的表單並在以後完成。

這個問題的最佳方法是什麼?

回答