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
-------------
def import
#json= params[:data]
@details = JSON.parse(json)
@profiles = Profile.where(@details)
respond_to do |format|
puts(render :json =>@profiles,:except =>
[:profileUpdatedDate, :profileCreatedDate,:profileAddOrUpdate,:profileStatus]);
end
end
Output
---------
Started GET "/webserviceapi/import" for 127.0.0.1 at Fri Dec 09
15:27:16 +0530 2
011
Processing by WebserviceapiController#import as HTML
←[1m←[36mProfile Load (1.0ms)←[0m ←[1mSELECT `profiles`.* FROM
`profiles` WHE
RE `profiles`.`profileId` = ''shanibskk123''←[0m
Completed 406 Not Acceptable in 102ms (Views: 7.0ms | ActiveRecord:
6.0ms)
[{"profileSex":null,"profileFirstName":null,"profileEducation":null,"profileAge"
:null,"profileWeight":null,"id":
3,"profileId":"shanibkk150467","profileRelation"
:null,"profileHeight":null,"profilePassword":"7c4a8d09ca3762af61e59520943dc26494
f8941b","profilePost":null,"profileMobileNumber":"9961977905","profileLastName":
null,"profileEmail":"shanibkk150467"}]
Started GET "/webserviceapi/import" for 127.0.0.1 at Fri Dec 09
15:30:33 +0530 2
011
Processing by WebserviceapiController#import as HTML
←[1m←[35mProfile Load (1.0ms)←[0m SELECT `profiles`.* FROM
`profiles` WHERE `
profiles`.`profileId` = ''shanibkk150467''
Completed 406 Not Acceptable in 49ms (Views: 15.0ms | ActiveRecord:
10.0ms)
______________________________________________________________________________________________
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.