I created simple scaffold, it has the destroy method with
respond_to do |format|
format.html { redirect_to :action => "index", :status => 302 }
format.json { head :ok }
end
end
when I click "Des开发者_StackOverflow中文版troy", I see the page with words "You are being redirected." where word "redirected" is link to the posts_path. what should i do to fix this bug?
I know this question is old, but I found the comment from Robert Reiz on the question helped me solve the same issue. I use the gem decent_exposure
, and I had a model called Location
. In the controller, expose(:location)
creates a method that breaks the redirect. Location
is now Place
.
I would pull out the :status => 302' option and double check that my Destroy link has
:method => 'delete'set. If the
:method` isn't set on the link then you will be redirected to your index action.
If you are using nginx with rails. Add the config below to nginx.
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
Send proper status code:
redirect_to root_path, notice: SUCCESS_MSG, status: :found
精彩评论