我有一些代码,我有一个:通知,它只是有选择地显示。
这是代码
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
从 :index 视图重定向到 :index 时,通知无法正确显示。看一下 Firebug 的网络控制台,有一个 GET(在此处插入 url)?notice=(通知文本),当通知正确显示时,它不会出现在其他页面中。
我正在使用 authlogic,只是基本的,使用本教程进行设置http://www.logansbailey.com/2010/10/06/how-to-setup-authlogic-in-rails-3/ http://www.logansbailey.com/2010/10/06/how-to-setup-authlogic-in-rails-3/。我将不胜感激任何帮助。谢谢。
我猜 Ruby 是这么想的:notice
是 url 属性的一部分,而不是 options 属性的一部分。尝试这个:
redirect_to({:action => :index}, {:notice => 'Succesfully assigned job'})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)