I generated an API-only rails app with Rails 5 via rails new <application-name> --api
. I've decided I want to include a view for testing some things and am having issues getting a view to load.
I created a users/index.html.erb file with some text and my controller is now simply def index; end
but there is nothing appearing when I hit the /users URL. I also tried commenting out the # config.api_only = true
in config/application.rb but that didn't affect anything. Any suggestions on how to proceed?
You don't need to uncomment config.api_only = true
for this purpose, just inherit your controller from ActionController::Base
, or do it in your ApplicationController
(default for common rails generation).
Code:
YourController < ActionController::Base
ApplicationController < ActionController::Base
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With