Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails: attach some data to "head :ok" response

In rails it is common practice to send a "head :ok" in response to a request. (https://github.com/search?l=Ruby&p=7&q=%22head+%3Aok%22&type=Code&utf8=%E2%9C%93)

Is it possible to send an json hash along with it?

like image 514
american-ninja-warrior Avatar asked Oct 19 '25 05:10

american-ninja-warrior


1 Answers

Is it possible to send an json hash along with it?

No.

head :ok sets render to return an empty response (so just the header, no body) with status 200. head :ok is shorthand for render nothing: true, status: :ok.
Here's a list of all the :status options you can use for setting the appropriate status code.

like image 176
Philidor Avatar answered Oct 21 '25 20:10

Philidor