Jordan
Jordan

Reputation: 2758

Rails double encoding my json

So I am trying to return an object which contains an array of other objects and i am getting back the objects all escaped eg(\"name\":\"My Name\"). I'm sure the problem is i am double encoding but I'm a ruby n00b so I am not sure how to do this properly

@Results = Marker.where("ID = '#{params[:id]}' and Stop_Id IS null").all

format.all { render json: { :Results => @Results.to_json(:include => :stops) } }

Thanks in advance!

Upvotes: 0

Views: 696

Answers (1)

apneadiving
apneadiving

Reputation: 115521

You should override the as_json method in your model.

See here for advice.

Upvotes: 1

Related Questions