2016-08-23 74 views
1

rails 4.2,respond_with和非实例级别respond_to已被转移到responders宝石。如果我想写一个json响应,所以我不需要responders宝石,这个SO question给出了一些替代方案。然而,是否有一个轨道4.2或轨道5指南,处理非深度回应的主题?使用什么而不是respond_with

+0

可能重复:http://stackoverflow.com/questions/28422845/respond-with-alternatives-in-rails-4-2-for-backbone – codyeatworld

回答

1

您可以通过将路由绑定到routes.rb文件中的格式来处理此问题。

EX。

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

Here are the Docs

+0

这是有用的,但它看起来好像没有深入讨论这个主题的具体指南。 – Obromios