Why does Rails 4.2 + responders keeps telling me to add responders to the Gemfile?

前端 未结 5 839
不思量自难忘°
不思量自难忘° 2020-12-19 06:16

I\'m upgrading a Rails 4.1.8 app (also using rails-api ~> 0.3.1) to 4.2.0.rc2 and would like to retain the respond_with functionality. I\'ve added respon

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 06:31

    Looks like it was a responders/rails-api incompatibility. I tried responders :location in the ApplicationController and would get a backtrace with undefined method 'responders' for ApplicationController:Class (NoMethodError), leading me to believe that the responders gem adds the responders class method to ActionController::Base. Since rails-api has your controllers inherit from ActionController::API, the responders methods wouldn't, in effect, get added to my ApplicationController.

    Confirmed: responders/lib/responders/controller_method.rb

    I tried extending my ApplicationController with Responders::ControllerMethod, but that didn't get me around the problem.

    My solution, effectively, was to drop using rails-api, then ApplicationController < ActionController::Base.

提交回复
热议问题