Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
关于使用 JSON 更新资源的一个难题:
https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/action_controller/metal/responder.rb#L201
当 GUI 想要一个好的回复来更新一个对象时,它应该做什么?我必须求助于显式渲染吗?
响应是来自的204 No Content默认行为respond_with。如果您想要不同的东西,或者如果您想要始终如一的不同行为,您可以进行显式渲染,您可以定义自己的ActionController::Responder子类。
204 No Content
respond_with
ActionController::Responder
我建议阅读默认响应者的来源,并在此处查看其他一些:
https://github.com/plataformatec/responders