Move respond_with to the responders gem #16526

Merged
merged 3 commits into from Aug 17, 2014

Conversation

Projects
None yet
@josevalim
Contributor

josevalim commented Aug 16, 2014

respond_with (and consequently the class-level respond_to)
are being removed from Rails. Instead of moving it to a 3rd
library, the functionality will be moved to responders gem
(at github.com/plataformatec/responders) which already provides
some responders extensions.

@seuros

This comment has been minimized.

Show comment
Hide comment
@seuros

seuros Aug 16, 2014

Member

caching_with_rails.md
contributing_to_ruby_on_rails.md

Member

seuros commented Aug 16, 2014

caching_with_rails.md
contributing_to_ruby_on_rails.md

@josevalim

This comment has been minimized.

Show comment
Hide comment
@josevalim

josevalim Aug 16, 2014

Contributor

@seuros good catch, thanks!

Contributor

josevalim commented Aug 16, 2014

@seuros good catch, thanks!

@@ -21,7 +19,7 @@ def zero
def create
ActiveRecord::LogSubscriber.runtime += 100
project = Project.last
- respond_with(project, location: url_for(action: :show))
+ redirect_to "/"

This comment has been minimized.

@seuros

seuros Aug 16, 2014

Member

shouldn't be ?

redirect_to url_for(action: :show, id: project.id)
@seuros

seuros Aug 16, 2014

Member

shouldn't be ?

redirect_to url_for(action: :show, id: project.id)

This comment has been minimized.

@josevalim

josevalim Aug 16, 2014

Contributor

We are not testing the redirect location, it can be anything.

@josevalim

josevalim Aug 16, 2014

Contributor

We are not testing the redirect location, it can be anything.

@robin850

This comment has been minimized.

Show comment
Hide comment
@robin850

robin850 Aug 17, 2014

Member

Nice work ! As for the responders gem, once you're sure about the version you'll pick for the next release, could you please add it to the generated Gemfile in new applications ? Also I guess you can mention this removal plus the gem name in the upgrading guide. Thanks ! :-)

Member

robin850 commented Aug 17, 2014

Nice work ! As for the responders gem, once you're sure about the version you'll pick for the next release, could you please add it to the generated Gemfile in new applications ? Also I guess you can mention this removal plus the gem name in the upgrading guide. Thanks ! :-)

@robin850 robin850 added railties and removed railties labels Aug 17, 2014

@robin850 robin850 added this to the 4.2.0 milestone Aug 17, 2014

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Aug 17, 2014

Member

👍

@robin850 I don't think we'll default to adding the gem in the Gemfile for new apps.

👍

@robin850 I don't think we'll default to adding the gem in the Gemfile for new apps.

josevalim added some commits Aug 16, 2014

Move respond_with to the responders gem
respond_with (and consequently the class-level respond_to)
are being removed from Rails. Instead of moving it to a 3rd
library, the functionality will be moved to responders gem
(at github.com/plataformatec/responders) which already provides
some responders extensions.

josevalim added a commit that referenced this pull request Aug 17, 2014

Merge pull request #16526 from rails/jv-no-responders
Move respond_with to the responders gem

@josevalim josevalim merged commit bf5b696 into master Aug 17, 2014

@josevalim josevalim deleted the jv-no-responders branch Aug 17, 2014

@kaluznyo kaluznyo referenced this pull request in straydogstudio/axlsx_rails Aug 20, 2014

Closed

Doesn't work with rails 4.2 #24

@guilhermesimoes

This comment has been minimized.

Show comment
Hide comment
@guilhermesimoes

guilhermesimoes Aug 20, 2014

What was the rationale for removing this feature? It saw little use?

What was the rationale for removing this feature? It saw little use?

@matthewd

This comment has been minimized.

Show comment
Hide comment
@guilhermesimoes

This comment has been minimized.

Show comment
Hide comment
@guilhermesimoes

guilhermesimoes Aug 23, 2014

Thanks! Good to know.

Thanks! Good to know.

@runwaldarshu

This comment has been minimized.

Show comment
Hide comment
@runwaldarshu

runwaldarshu Jan 6, 2015

I am wondering if I add responders gem into gemspec why will it still need to be added in Gemfile where gemspec is included in Gemfile.
I am seeing failures while doing that.

I am wondering if I add responders gem into gemspec why will it still need to be added in Gemfile where gemspec is included in Gemfile.
I am seeing failures while doing that.

@jedschneider

This comment has been minimized.

Show comment
Hide comment
@jedschneider

jedschneider Jan 28, 2015

Is rails not using semantic versioning? This should not have been included in a minor release without providing backwards support for 4.x apps that use responders. A deprecation warning and request to move would have been OK, but breaking changes should have been done at 5.0.

Is rails not using semantic versioning? This should not have been included in a minor release without providing backwards support for 4.x apps that use responders. A deprecation warning and request to move would have been OK, but breaking changes should have been done at 5.0.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jan 28, 2015

Member

Is rails not using semantic versioning?

http://guides.rubyonrails.org/maintenance_policy.html

This should not have been included in a minor release without providing backwards support for 4.x apps that use responders.

http://guides.rubyonrails.org/4_2_release_notes.html#respond-with-class-level-respond-to

Member

rafaelfranca commented Jan 28, 2015

Is rails not using semantic versioning?

http://guides.rubyonrails.org/maintenance_policy.html

This should not have been included in a minor release without providing backwards support for 4.x apps that use responders.

http://guides.rubyonrails.org/4_2_release_notes.html#respond-with-class-level-respond-to

@chancancode

This comment has been minimized.

Show comment
Hide comment
@chancancode

chancancode Jan 28, 2015

Member

@runwaldarshu when adding something to the gemspec, it will add that library to your gem's dependency graph, so that when you gem install your-gem, rubygems would know that it needs to install your-dependency too. However, it does not automatically require your-dependency for you.

On the other hand, the Gemfile in your-library (as opposed to your Rails app's Gemfile) is only used for development purpose, and does not affect the dependency graph of your published gem (your-library). However, adding something to the Gemfile also, by default, requires it automatically (unless you specified require: false).

So, if you are packaging a gem/engine that uses responsers, your set up should probably look like this:

# your_engine/your_engine.gemspec

  ...
  s.add_dependency "responsers", "..."
  ...
# your_engine/Gemfile

gemspec
# your_engine/lib/your_engine.rb
require 'your_engine/version'
...
require 'responders'
...
Member

chancancode commented Jan 28, 2015

@runwaldarshu when adding something to the gemspec, it will add that library to your gem's dependency graph, so that when you gem install your-gem, rubygems would know that it needs to install your-dependency too. However, it does not automatically require your-dependency for you.

On the other hand, the Gemfile in your-library (as opposed to your Rails app's Gemfile) is only used for development purpose, and does not affect the dependency graph of your published gem (your-library). However, adding something to the Gemfile also, by default, requires it automatically (unless you specified require: false).

So, if you are packaging a gem/engine that uses responsers, your set up should probably look like this:

# your_engine/your_engine.gemspec

  ...
  s.add_dependency "responsers", "..."
  ...
# your_engine/Gemfile

gemspec
# your_engine/lib/your_engine.rb
require 'your_engine/version'
...
require 'responders'
...
@jedschneider

This comment has been minimized.

Show comment
Hide comment
@jedschneider

jedschneider Jan 28, 2015

@rafaelfranca thanks for the clarification. Working with a student that is having a hard time getting responders loaded in her project. Since my last comment I upgraded an app to 4.2 without issue, but devise was included so it was already complaining that I needed the responders gem for that dependency to work. For me it was seamless, but apparently not for everyone.

@rafaelfranca thanks for the clarification. Working with a student that is having a hard time getting responders loaded in her project. Since my last comment I upgraded an app to 4.2 without issue, but devise was included so it was already complaining that I needed the responders gem for that dependency to work. For me it was seamless, but apparently not for everyone.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jan 28, 2015

Member

@jedschneider the version of Devise compatible with Rails 4.2 already include responders gem as dependecy https://github.com/plataformatec/devise/blob/v3.4.1/devise.gemspec#L28

Member

rafaelfranca commented Jan 28, 2015

@jedschneider the version of Devise compatible with Rails 4.2 already include responders gem as dependecy https://github.com/plataformatec/devise/blob/v3.4.1/devise.gemspec#L28

@jedschneider

This comment has been minimized.

Show comment
Hide comment
@jedschneider

jedschneider Jan 28, 2015

@rafaelfranca FWIW had to bundle update devise as well to pick up that change (and it did work). But I'd probably rather leave the dependency fully qualified in my Gemfile anyway, since I'm using responders directly in my controllers. Thanks again.

@rafaelfranca FWIW had to bundle update devise as well to pick up that change (and it did work). But I'd probably rather leave the dependency fully qualified in my Gemfile anyway, since I'm using responders directly in my controllers. Thanks again.

@jedschneider

This comment has been minimized.

Show comment
Hide comment
@jedschneider

jedschneider Jan 28, 2015

@rafaelfranca worked through the student's issue. I think the confusion was associated with the installation of the responders gem, and the bootstrapping that it does with the generator, vs what you need to do directly in rails (just require). I'm not sure thats worth a note or not.

@rafaelfranca worked through the student's issue. I think the confusion was associated with the installation of the responders gem, and the bootstrapping that it does with the generator, vs what you need to do directly in rails (just require). I'm not sure thats worth a note or not.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jan 28, 2015

Member

@jedschneider yeah, installation of responders seems to confuse people. Maybe we should make explicit that the install process is optional at responders README.

Member

rafaelfranca commented Jan 28, 2015

@jedschneider yeah, installation of responders seems to confuse people. Maybe we should make explicit that the install process is optional at responders README.

@jedschneider jedschneider referenced this pull request in plataformatec/responders Jan 28, 2015

Merged

add note for people upgrading from rails 4.1 #114

@lacostenycoder

This comment has been minimized.

Show comment
Hide comment
@lacostenycoder

lacostenycoder Apr 21, 2015

I've read through this but don't quite understand "why" the responders have been removed from rails. Is there a better way of doing this in rails 4.2 ? I should have checked here fires. Never mind.
http://stackoverflow.com/questions/25998437/why-is-respond-with-being-removed-from-rails-4-2-into-its-own-gem

I've read through this but don't quite understand "why" the responders have been removed from rails. Is there a better way of doing this in rails 4.2 ? I should have checked here fires. Never mind.
http://stackoverflow.com/questions/25998437/why-is-respond-with-being-removed-from-rails-4-2-into-its-own-gem

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Apr 21, 2015

Member

@lacostenycoder with variants and things like jbuilder this feature becomes out of date. The idea of variants would not work with it so we chose to just remove from the core. Pay attention that the feature is still supported, just outside of the default Rails stack.

Member

rafaelfranca commented Apr 21, 2015

@lacostenycoder with variants and things like jbuilder this feature becomes out of date. The idea of variants would not work with it so we chose to just remove from the core. Pay attention that the feature is still supported, just outside of the default Rails stack.

@dkaplan88 dkaplan88 referenced this pull request in enova/landable Apr 28, 2015

Closed

Rails 4.2 Support -> ActionController::Responder #59

@dmk dmk referenced this pull request in rubykube/peatio Dec 18, 2017

Merged

Add 'responders' gem #120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment