There is some unexpected behavior when creating the api for the Rails 3.0.3 application that runs json.
Below is the controller. Question about respond_with . I already have respond_to :json in the application controller.
The create action just works, and the data is also sent back after creation.
But the update respond_with does not return any data.
The response body is empty.
def create line = get_line input_header = line.input_headers.create(params[:input_header]) respond_with(input_header, :location => api_v1_line_input_header_url(line,input_header)) end def show input_header = get_input_header respond_with(input_header.to_json) end def update input_header = get_input_header input_header.update_attributes(params[:input_header]) respond_with(input_header, :location => api_v1_line_input_header_url(input_header.line,input_header))
When I use render :json => input_header instead of respond_with , it works. Why is this?
source share