alexs333
alexs333

Reputation: 12593

Responding with custom JSON

I have a very simple task but got confused.

I need my action to respond with very simple JSON:

{"valid": true}

What do I need to write in my controller?

render :json => ......

Upvotes: 0

Views: 222

Answers (2)

Dave Newton
Dave Newton

Reputation: 160311

render :json => { valid: true }

Rails should call to_json automatically.

Upvotes: 2

Kevin Bedell
Kevin Bedell

Reputation: 13424

Have you tried:

render :json => {"valid" => true}

Upvotes: 1

Related Questions