Closed srinatha closed 12 years ago
Here is my sample app that works with your first issue:
_app/controllers/jobscontroller.rb
class JobsController < ApplicationController
respond_to :json
def index
@jobs = Job.all
# additional example @jobs = []
end
end
_app/views/jobs/index.json.jsonbuilder
results @jobs do |job|
description job.body
end
Responses:
{ "results": [{ "description": "test" }] }
// And for the empty array test
{ "results": [] }
Could you provide the full backtrace to your error and the source of your JobsController for me?
As for issue 2, I don't understand your question, could you rephrase it? More specifically how you intend to use that string. You are able to just put that as the value in a JSON key/value pair.
Issue 2 :
In database column description i am saving text like this :
<p>
Find new snake-handlers and make sure they stay happy and challenged.</p>
This is showing like this on screen when used job.description : "\"
\r\n\tFind new snake-handlers and make sure they stay happy and challenged.
\r\n\""Per your back trace, you are using the API::V1::JobsController
, but in the code you posted it's just JobsController
. Did you modify it before pasting it here? No issue with that, just may help with finding the issue since I am not sure how that controller would render app/views/jobs/index.json.json_builder
when you are using the API::V1
namespace.
Additionally...
rails console
when you type Job.all
and Job.count
?If none of that makes any difference, could you create a sample application and post that in your profile?
Thanks!
Regarding issue #2, I am also unable to reproduce this:
{
"results": [
{
"title": "Rails guy",
"description": "<p>\nFind new snake-handlers and make sure they stay happy and challenged.</p>"
}
]
}
Going to close this due to lack of example support.
How to parse text coming like this - "\"
\r\n\tStrong knowledge of GAAP and Basel standards for valuing snakes.
\r\n\""I am facing these two issues while using json (1.6.5, 1.5.3) json_builder (3.1.4) json_pure (1.5.3)