Commands when building the Rails API
docker-compose run web rails new . --force --database=mysql --api --skip-bundle
You have now generated the Rails API. ↓ I want to return to normal Rails. ↓ In the same directory, this time pulling --api,
docker-compose run web rails new . --force --database=mysql --skip-bundle
The file created during the Rails API remains as it is.
application_controller.rb
- class ApplicationController < ActionController::API
+ class ApplicationController < ActionController::Base
application.rb
- config.api_only = false
All you have to do now is run the required commands in docker.
docker-compose build
docker-compose run web rails db:create
docker-compose up -d
Supplement https://shakacode.gitbooks.io/react-on-rails/content/docs/additional-reading/convert-rails-5-api-only-app.html https://stackoverflow.com/questions/36669981/how-do-you-convert-a-rails-5-api-app-to-a-rails-app-that-can-act-as-both-api-and
Recommended Posts