3
我有一些代码,我有一个:notice,它只是有选择地显示出来。Rails 3声明在使用Redirect_To时不起作用
下面的代码
respond_to do |format|
if @userhj.save
format.html { redirect_to(:action => :index, :notice => 'Succesfully assigned job') }
format.xml { render :xml => @userhj, :status => :created, :location => @userhj }
else
format.html { redirect_to(:root, :notice => 'Duplicate job assignment') }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
当重定向到:从指数:指数来看,该通知不显示正确。看看Firebug的网络控制台,有一个GET(插入url)?notice =(notice text),当通知显示正确时,它不会出现在其他页面中。
我使用authlogic,只是基本的,使用本教程http://www.logansbailey.com/2010/10/06/how-to-setup-authlogic-in-rails-3/设置。我会很感激任何帮助。谢谢。
哦,哇,这完美的作品!无法告诉你这是多么的疯狂!谢谢! – CCSab 2011-05-02 03:15:31
谢谢。我必须传递一个额外的参数并一起注意。直到找到你的答案,我才能完成工作。 redirect_to({:controller =>'sales',:action =>'new',:linked_id => @ purchase.id},{:notice =>'notice。'}) – Bot 2013-12-11 20:24:21