Obromios
Obromios

Reputation: 16383

What to use instead of respond_with

From rails 4.2, respond_with and non-instance level respond_to have been moved to the responders gem. If I want to write a json response so I do not need the responders gem, this SO question gives some alternatives. However, is there a rails 4.2 or rails 5 guide that deals the topic of responding to non-html in depth?

Upvotes: 4

Views: 790

Answers (1)

blnc
blnc

Reputation: 4404

You can handle this by binding the route to a format in the routes.rb file.

EX.

get 'my-json-route', to: 'controller#action', defaults: { format: :json }

Here are the Docs

Upvotes: 1

Related Questions