1
POST 요청을 리디렉션하려고하면 레일의 플래시 해시가 지워집니다.ruby-on-rails에서 POST 요청을 리디렉션하면 플래시 해시가 지워집니다.
리디렉션은 초기 요청이 GET 인 경우 잘 작동합니다.
설정에서/routes.rb
응용 프로그램/컨트롤러/test_controller.rb에서post 'test/hello'
#get 'test/hello' #uncomment this line and comment out the post and the flash is preserved
get 'test/goodbye'
응용 프로그램에서
def hello
respond_to do |format|
format.html do
redirect_to movies_goodbye_url, :notice => "I disappear on post requests"
end
end
end
def goodbye
end
/보기/테스트/goodbye.html.haml
%h1 Test#goodbye
%p#alert= alert
%p#notice= notice
이 작업을 통해 오류 사례에서 내 기존보기 중 하나로 리디렉션되는 양식 제출의 게시물을 처리 할 수 있습니다. 레일스에 익숙하지 않기 때문에이 유스 케이스를 처리 할 수있는 더 좋은 방법이 있다면 알려 주시기 바랍니다.
한 멋진 캐치! 레일스는 왜 이런 식으로 작동합니까 ??? 버그 추적기에 버그로 제출해야합니까? –