[英]Rails respond_with not… responding
我有一个在Rails上运行的Backbone.js应用,当我更新时,我想返回该对象。 我有以下控制器未响应我的json请求。
class EventsController < ApplicationController
respond_to :html, :json
def update
@event = Event.find(params[:id])
@event.update_attributes(params[:event])
respond_with @event
end
end
它在控制台中显示以下内容:
(1.9ms) COMMIT
Completed 204 No Content in 12ms (ActiveRecord: 0.0ms)
但是,下面的方法正在工作...但是它违背了response_to / with的目的。
class EventsController < ApplicationController
respond_to :html, :json
def update
@event = Event.find(params[:id])
respond_to do |format|
if @event.update_attributes(params[:event])
format.json {render json: @event}
end
end
end
end
这在控制台中显示以下内容:
(0.1ms) COMMIT
**A bunch of Select Queries**
Completed 200 OK in 27ms (Views: 10.2ms | ActiveRecord: 5.0ms)
我很困惑
我遇到了一些问题。 显然是这样的。 在rails github上看到这个问题: https : //github.com/rails/rails/issues/9069
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.