active_model_serializers
active_model_serializers copied to clipboard
Add missing api_controller that Rails 5 generator expects
Purpose
This allows AMS 0.9x to be used with Rails 5, without any errors.
Changes
Added an api_controller.rb
template that the Rails 5 Generator expects.
Caveats
This fixes the main issue that I was facing in #1923 but as I experiment more, there might be more issues getting Rails 5, AMS 0.9x to play well.
Related GitHub issues
#1923
Additional helpful information
Thanks @bf4 @remear for your help debugging this issue.
@oyeanuj Sorry for the delay in responding to this: what's the error? I'm not sure why AMS should be adding a controller generator template
@bf4 So, it seems that Rails 5 in API mode expects there to be these controller generators which were missing and causing errors mentioned in #1923.
Also, to point out that 0.9x already had controller template but it was named controller.rb
. In API mode, it seems to expect the controller generator to be named as api_controller.rb
.
ref
- rails template https://github.com/rails/rails/blob/5-1-stable/railties/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb
- devise template https://github.com/plataformatec/responders/commit/8f443b2f185b04816cb0e990d50832a015ca2594
@oyeanuj would you be up to rebase and force push this?
I think it might make more sense to avoid the api controller template. There's nothing different in it from the Rails default, right?
module Rails
module Generators
class ScaffoldControllerGenerator
- if Rails::VERSION::MAJOR >= 4
+ if Rails::VERSION::MAJOR >= 4 && ApplicationController < ActionController::Base