:status => :ok sets the status code of the HTTP header, i.e. same as :status => 200 . If you want to add something to the response body, you will need to add it explicitly, for example.
respond_with({:conns => @conns, :status => :success}.to_json)
EDIT
OK, so this will not work. If you don't need to respond to anything other than JSON, you can just use the good old render :
render :json => { :conns => @conns, :status => :success }
If you need to host multiple types of responses using the bright and shiny new respond_with method, you can create a class that responds to as_json :
class JsonResponse def initialize(data,status) @data = data @status = status end def as_json(options={}) { :data => @data, :status => @status } end end
Then name it like this:
@conns = Connection.all respond_with(JsonResponse.new(@conns,"success"))
source share