我已經在我的控制器爲什麼:通知中未顯示重定向後對Rails 3
def create
@tv_show = TvShow.new(params[:tv_show])
respond_to do |format|
if @tv_show.save
format.html { redirect_to(tv_shows_path, :notice => 'Tv show was successfully created.') }
format.xml { render :xml => @tv_show, :status => :created, :location => @tv_show }
else
format.html { render :action => "new" }
format.xml { render :xml => @tv_show.errors, :status => :unprocessable_entity }
end
end
end
下面的代碼和我tv_shows/index.html.erb
<div id="notice"><%= notice %></div>
但當以下我創建了一個新條目,在重定向到tv_shows_path之後,通知消息不會出現。有沒有人知道爲什麼?
我覺得肖恩是正確的關於View,它應該是「閃[:聲明]」。 – 2011-01-26 00:24:53
我讀過這將是與軌道版本3的新方式...但我會嘗試您的建議,謝謝! – maveonair 2011-01-26 06:36:26
@Fabian:這是否適合你? – Shaun 2011-01-28 04:32:15