我想在重定向后将 2 个字符串传递给视图。控制器:
def create
@rating = Rating.new(params[:rating])
respond_to do |format|
if @rating.save
format.html { redirect_to @rating, :notice => 'Got It!' ,
:notice_small => 'Your photo has been uploaded. good luck with it\'s coolness rating!' }
format.json { render :json => @rating, :status => :created, :location => @rating }
else
format.html { render :action => "new" }
format.json { render :json => @rating.errors, :status => :unprocessable_entity }
end
end
end
风景:
<p id="notice" class="big_notice"><%= notice %></p>
<% if defined? notice_small %>
<p id="small_notice" class="small_notice"><%= notice_small %></p>
<% end %>
通知字符串抛出但notice_small 没有,为什么?