Display View in Rails 5 API

I created an API-only rail application with Rails 5 through rails new <application-name> --api . I decided that I want to include a view for testing some things, and I'm having problems loading.

I created a users / index.html.erb file with some text, and now my controller is now just def index; end def index; end , but I don’t see anything when I click on the / users url. I also tried commenting out # config.api_only = true in config / application.rb, but that didn't affect anything. Any suggestions on how to proceed?

+5
source share
1 answer

You do not need to uncomment config.api_only = true for this purpose, just inherit your controller from ActionController::Base or do it in your ApplicationController (by default to generate common rails).

code:

  • Only for this controller YourController < ActionController::Base
  • For all applications, ApplicationController < ActionController::Base
+13
source

Source: https://habr.com/ru/post/1257751/


All Articles