Rails 3 Notices don't work when using Redirect_To
I've got some code I have a :notice, which is only showing up selectively.
Here's the code
respond_to do |format|
if @userhj.save
format.html { redirect_to(:action => :index, :notice => 'Succesfully assigned job') }
format.xml { render :xml => @us开发者_如何学Pythonerhj, :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
When redirecting to :index from the :index view, the notices don't show up properly. Taking a look at Firebug's net console, there's a GET (insert url here)?notice=(notice text), which doesn't appear in other pages when the notices do show up correctly.
I'm using authlogic, just basic, set up using this tutorial http://www.logansbailey.com/2010/10/06/how-to-setup-authlogic-in-rails-3/. I'd appreciate any help with this. Thanks.
I'm guessing that Ruby is thinking that :notice
is part of the url attribute rather than the options attribute. Try this:
redirect_to({:action => :index}, {:notice => 'Succesfully assigned job'})
精彩评论