2010-03-24 36 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方法这种形式。为了使问题复杂化,用户可以保存半完成的表单并在以后完成。

这个问题的最佳方法是什么?

回答