44
I want to redirect to the a models index view after saving my model.
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
I've tried
format.html { render action: "index", notice: 'Test was successfully created.' }
but I get the following error in /app/views/tests/index.html.erb -
undefined method `each' for nil:NilClass
Any idea what's going wrong?