Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
508 views
in Technique[技术] by (71.8m points)

ruby - Why is respond_with being removed from rails 4.2 into it's own gem?

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

Beta release notes.

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...