Send a hash of form form parameters as response content

I am trying to send params hashes of forms to the original referrer:

redirect_to request.referer, flash: { message: params }

I am sending a flash message now.

Is there a way to send it back as response content or something instead of flash. I can not find the correct syntax

+4
source share
1 answer

As far as I can tell, Rails does not simplify the issue of the redirect and sets up the body of the response. To do this, you need to manually redirect. For instance.

response.headers['Location'] = request.referer
render :json => params, :status => :moved_permanently

Please note that not all requests contain a referent, so you must specify a return location for redirection. For instance.

response.headers['Location'] = request.referer || '/somewhere'
0
source

Source: https://habr.com/ru/post/1541790/


All Articles