나는 다음과 같은 컨트롤러의 액션이 있습니다레일에서 아약스 요청을 대신 JS의 HTML 렌더링
def create
@board = Board.new(params[:board])
respond_to do |format|
if @board.save
set_board_session @board
set_new_board
format.js { render :action => "show" } #<== here I want to render html no js
else
format.js { render :action => "new" }
end
end
end
내가 show.html.erb 동작하지 아약스의 show.js.erb 조치를 렌더링 할 의뢰.
어떻게하면됩니까?
UPDATE는
이 나를 위해 작동하는 것 같다 :
나는 내 응용 프로그램 컨트롤러에 넣고 :def redirect_to(options = {}, response_status = {})
if request.xhr?
render(:show) {|page| page.redirect_to(options)}
else
super(options, response_status)
end
end
가 지금은 Ajax 호출로 리디렉션 할 수 있습니다. 이
forum에
format.js {redirect_to @board}
감사 :
이 질문이 도움이됩니까? http://stackoverflow.com/questions/339130/how-do-i-render-a-partial-of-a-different-format-in-rails – spike
Thanks Spike. 정확히 내가 찾던게 아니야. 나는 AJAX 요청을위한 js 페이지 대신 html 페이지를 렌더링하고 싶다. – chell
전체 파일 이름 제공에 대한 제안 : 파일이 작동하지 않습니까? 내 테스트가 작동하는 것 같았다. (: file => "controller/show.html.erb") – spike