ROR return JSON with 406 Not Acceptable error

When we return JSON output using 'render :json =>@profiles', the output will return the required results with a 406 error. How can avoid that 406 Not Acceptable error ?

Function

Hi Krisnaraj,

When we return JSON output using 'render :json =>@profiles', the output will return the required results with a 406 error. How can avoid that 406 Not Acceptable error ?

This bit me yesterday. You've told rails that you're going to respond differently depending on what format the client requested by using respond_to. But then didn't tell rails what those response options are. You need to put a format block around the response.

Function ------------- def import #json= params[:data] @details = JSON.parse(json) @profiles = Profile.where(@details) respond_to do |format|

         format.js{

 puts\(render :json =>@profiles,:except =>

[:profileUpdatedDate, :profileCreatedDate,:profileAddOrUpdate,:profileStatus]);

         }

end end

HTH, Bill