Rails 4.1 ActionController::UnknownFormat error for respond_with using AngularJS
it seams that having
respond_to :json
is valid when the routes defines json as the default
scope :api, defaults: {format: :json} do resources :resourcesend
to not allow the html in the Controller simply add the following to the method
def new @resource = Resource.new respond_with(@resource) do |format| format.html { render nothing: true, status: :unauthorized } format.json { render :json => @resource.as_json } endend
In /app/assets/controllers/surveys_controller
you could change respond_with
to render json:
like so:
def index @surveys = Survey.all render json: @surveysend
That worked for me using Rails 4.1.5.
Solved it with the following amendment:
In /app/assets/controllers/surveys_controller, use
respond_to :json, :html
instead of just
respond_to :json