Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 695
Ryan-Neal Mes Avatar asked Sep 23 '14 15:09

Ryan-Neal Mes


1 Answers

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

like image 161
Whit Kemmey Avatar answered Oct 21 '22 00:10

Whit Kemmey