You are being redirected. rails 3.1

橙三吉。 提交于 2020-01-05 03:03:25

问题


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 "Destroy", 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?


回答1:


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.




回答2:


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.




回答3:


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;


来源:https://stackoverflow.com/questions/7338726/you-are-being-redirected-rails-3-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!