这是我的控制器中的代码..
def create
@batch = Batch.find(params[:batch_id])
@exam_group = ExamGroup.find(params[:exam_group_id])
@module = StudentAdditionalField.find(params[:module_id])
@question = Question.new(params[:question])
@question.student_additional_field_id = @module.id
@question.exam_group_id = @exam_group.id
if @question.save or request.post?
if ( @question.id == @module.questions )
flash[:notice] = "Total no of questions added"
redirect_to batch_exam_group_module_questions_path(@batch, @exam_group, @module), :id => @question_id
else
flash[:notice] = "Question Added"
redirect_to new_batch_exam_group_module_question_path(@batch, @exam_group, @module)
end
end
结尾
我的模块 sql 是
+----+--------+-----------+-------+
| id | name | questions | marks |
+----+--------+-----------+-------+
| 1 | Quants | 1 | 1 |
| 2 | Eng | 2 | 2 |
| 3 | Reason | 3 | 3 |
+----+--------+-----------+-------+
这里 if 语句没有得到只有 else 语句有效