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
我應該看到@games
作爲broswer JSON數據。
但我有,當我去/games.json
我看到的/games
的源代碼,其佈局等爲JSON(HTML代碼在頭」
一個錯字'@players = current_user.games'應該是'@games = current_user.games' – fl00r 2011-05-09 17:01:37
錯字這裏不是我的應用程序!(編輯) – amrnt 2011-05-09 17:07:53
views/games/index.haml應該是views/games/index.html.haml我剛剛檢查了一個我用erb製作的應用程序,它的工作正常......您是否嘗試過舊版的rails? – Gazler 2011-05-09 17:24:28