ActionController::API
does not include the ActionController::MimeResponds
module. If you want to use respond_to
you need to include MimeResponds
.
class ApplicationController < ActionController::API
include ActionController::MimeResponds
end
module Api
class MyController < ApplicationController
def method1
# ...
respond_to do |format|
format.xml { render(xml: "fdsfds") }
format.json { render(json: "fdsfdsfd" ) }
end
end
end
end
Source: ActionController::API docs