これが私のコントローラーのコードです..
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ステートメントのみを取得しません