保存模型后,我想重定向到a模型索引视图.
def create
@test = Test.new(params[:test])
respond_to do |format|
if @test.save
format.html { redirect_to @test, notice: 'test was successfully created.' }
else
format.html { render action: "new" }
end
end
end
我试过了
format.html { render action: "index", notice: 'Test was successfully created.' }
但是我在/app/views/tests/index中发现了以下错误.html.雇员再培训局-
undefined method `each' for nil:NilClass
知道怎么回事吗?