我還沒有行動的各個領域中的控制器JSON在軌道4,5不包含對象
def index
if UserDatum.find_by_user_id(current_user.id) == nil
redirect_to new_user_datum_path
end
@journal = Journal.new
authorize! :read, @journals
if params[:date]
@journals = Journal.all.where("user_id = #{current_user.id} and DATE(created_at) = DATE('#{params[:date]}')").order("created_at DESC")
@date = params[:date]
return
end
@journals = Journal.all.where("user_id = #{current_user.id} and DATE(created_at) = DATE('#{Time.now}')").order("created_at DESC")
end
當我與參數「日期」稱呼它必須返回JSON(我使用AJAX)。但這是我的JSON:
Object {id: 5, user_id: 31, systolic: 185, diastolic: 75, url: "http://localhost:3000/journals/5.json"} application.js?body=1:72
Object {id: 4, user_id: 31, systolic: 110, diastolic: 70, url: "http://localhost:3000/journals/4.json"} application.js?body=1:72
Object {id: 3, user_id: 31, systolic: 125, diastolic: 85, url: "http://localhost:3000/journals/3.json"} application.js?body=1:72
Object {id: 2, user_id: 31, systolic: 130, diastolic: 90, url: "http://localhost:3000/journals/2.json"} application.js?body=1:72
它必須包含'created_at'和'type_of_pressure'字段。但是當我試圖給他們打電話時,js會返回'未確定'。
可以發佈什麼是確切的錯誤? – Pavan