1

I know rails 1.2.3 is stale now but i have got a project in rails 1.2.3 to work on. I want to output the result in json format. i am using

render :json => @result.to_json and return

it gives me {success: "false"}

instead, i want {"success": "false"}

I cant go for an upgrade as on now.

Please suggest.

1
  • You've asked 19 questions, but haven't accepted an answer to any of them. Please go back and accept answers to your previous questions. Commented May 25, 2012 at 6:54

1 Answer 1

1

Try adding ActiveSupport::JSON.unquote_hash_key_identifiers = false to environment.rb.

Sign up to request clarification or add additional context in comments.

5 Comments

Above solution worked well on my local where i have multiple rails version staring from 1.2.3 to Rails 3 exist. But when i try this on my phusion passenger based server it says unidentified constant Active support. Configuration on server: Ruby 1.8.6 and Rails 2.3.5, 2.3.8
Make sure rails is loaded first. For Rails 2, you can move the code from environment.rb to an initializer.
Which code? Your solution is not clear . Please explain. My app is developed in rails 1.2.3
You're saying the error is showing up in Rails 2. The solution is only valid for Rails 1.2.
Solution - Adding the line "ActiveSupport::JSON.unquote_hash_key_identifiers = false" at the end of environment.rb worked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.