XML : Render XML Working But Render JSON Not

Working on a simple rails api and need to return the json, but unable to return it. Replacing json with xml worked for me and the code is returning the xml correctly but not the json.

  module Api    class AgendaController < ApplicationController        respond_to :json        def all        render json:Person.all      end      def default_serializer_options        {root:false}      end    end  end    

Now if i replace render json:Person.all with render xml:Person.all it's working perfectly.

My Routes.rb file

   namespace :api, constraints: {format: :json} do          get 'people' => 'agenda#all'      end    

Error:

NoMethodError in Api::AgendaController#all undefined method `idm' for #

   def all        render json: Person.all #ErrorHere      end    

No comments:

Post a Comment