2011-05-09 2 views
2

:html:json에 대한 작업을 수행하려고합니다.Rails 3.1에서`respond_with` 및`respond_to`에 대한 예상치 못한 동작이 발생했습니다.

class GamesController < ApplicationController 

    respond_to :html, :json 

    def index 
    @games = current_user.games 
    respond_with(@games) 
    end 

end 

내가 /games로 이동 예상보기 views/games/index.haml의 레이아웃을 볼 수 있고 내가 /games.json에 가면 내가 가지고있는이 broswer에서 JSON 데이터로 @games을 볼 수 있습니다. 내가 함께 /games의 소스 코드를 볼 수 /games.json에 갈 때

는하지만 내가 가진 것은 자사의 레이아웃 등 JSON (당신은 파일의 확장자에에 havve 헤더 "

+0

를 통해 오타'@players = current_user.games' 내 응용 프로그램에서 여기 @games = current_user.games' – fl00r

+0

오타하지'해야 ! (수정) – amrnt

+2

보기/게임/index.haml해야합니다. be views/games/index.html.haml 난 그냥 erb를 사용하는 응용 프로그램과 이것을 확인하고 잘 작동 ... 당신은 이전 버전의 레일 시도 했습니까? – Gazler

답변

2

에서 application/json와 HTML 코드로 내가이 렌더링 여부를하려는 레일을 말할

views/games/index.haml should be views/games/index.html.haml I just checked this with an app I made that uses erb and it works fine...Have you tried on an older version of rails?을 -!? Gazler