为什么respond_with被从rails 4.2中移除到它自己的gem中?

Rya*_*Mes 41 ruby ruby-on-rails

rails 4.2中, respond_with已从核心移出到响应者gem中.

Beta发行说明.

respond_with has moved out and into its own proper home with the responders gem.

有人可以解释一下原因吗?什么使响应者宝石成为适当的家?它留在Rails宝石有什么问题?

Whi*_*mey 60

David Heinemeier Hansson(Ruby on Rails的创建者)的基本原理:

我想借此机会将respond_with/class-level respond_to拆分为外部插件.我通常不喜欢使用这种模式的代码.它鼓励模型#to_json,它以隐藏代码的方式隐藏HTML和API响应之间的差异.

那么我们如何将它拆分为4.2的gem,具有当前行为,但也可以选择通过配置点获取此处建议的新行为.

在此链接进行全面讨论:

https://github.com/rails/rails/pull/12136#issuecomment-50216483