How do you render hashes as JSON in Rails 3?

When you specify a respond_to then in your actions you would make a matching respond_with.

Up vote 1 down vote favorite share g+ share fb share tw.

I have found how to render ActiveRecord objects in Rails 3, however I cannot figure out how to render any custom objects. I am writing an app without ActiveRecord. I tried doing something this: class AppController {'ok'=>true} } end end ruby-on-rails json api ruby-on-rails-3 link|improve this question asked Aug 13 '10 at 15:21Cory Gagliardi1215.

When you specify a respond_to, then in your actions you would make a matching respond_with: class AppControlls true } respond_with(hash) end end It looks like you're conflating the old respond_to do |format| style blocks with the new respond_to, respond_with syntax. This edgerails.info post explains it nicely.

This was very close. However, it does not automatically convert the hash to json. This was the final result: class AppControlls true }.

Json ) end end Thanks for the help.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions