【发布时间】:2012-05-03 21:42:56
【问题描述】:
我想在保存模型后重定向到模型索引视图。
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.erb 中收到以下错误 -
undefined method `each' for nil:NilClass
知道出了什么问题吗?
【问题讨论】:
-
对“每个”的调用在哪里?
-
已编辑问题 - 在索引视图中。
标签: ruby-on-rails ruby-on-rails-3