Reputation: 16383
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
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 }
Upvotes: 1