为什么 response_with 从 rails 4.2 中删除到它自己的 gem 中? [英] Why is respond_with being removed from rails 4.2 into it's own gem?

查看:21
本文介绍了为什么 response_with 从 rails 4.2 中删除到它自己的 gem 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rails 4.2 中,respond_with 已从核心移到响应宝石.

In rails 4.2 respond_with has been moved out of core into the responders gem.

测试版发行说明.

respond_with 带着响应者宝石搬出并搬进了自己的家.

谁能解释一下为什么?是什么让响应者宝石成为其合适的家?留在 Rails gem 中有什么问题?

Can someone please explain why? What makes the responders gem its proper home? What is wrong with it staying in the Rails gem?

推荐答案

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

Rationale from David Heinemeier Hansson (creator of Ruby on Rails):

我想借此机会拆分respond_with/class-levelresponse_to 到外部插件.我一般不喜欢使用这种模式产生的代码.它鼓励模型#to_json它以多种方式隐藏了 HTML 和 API 响应之间的差异使代码变得复杂.

I'd like to take this opportunity to split respond_with/class-level respond_to into an external plugin. I'm generally not a fan of the code that comes out of using this pattern. It encourages model#to_json and it hides the difference between HTML and API responses in ways that convolute the code.

那么我们如何将其拆分为 4.2 的 gem,使用当前行为,但也可以选择按照建议获得新行为这里通过一个配置点.

So how about we split this into a gem for 4.2, with the current behavior, but also with an option to get the new behavior as suggested here through a configuration point.

在此链接进行完整讨论:

Full discussion at this link:

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

这篇关于为什么 response_with 从 rails 4.2 中删除到它自己的 gem 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆