I originally posted this as an issue on rails_api GitHub, but am now posting it here due to inactivity.
I\'m trying to use rails_admin
with a Rails 5 API ap
If I were you, I try isolate API and RailsAdmin controllers. I think this must work:
class ApplicationController < ActionController::API
include Knock::Authenticatable
include Pundit
end
class RailsAdminCustomController < ApplicationController
# RailsAdmin support
include AbstractController::Helpers
include ActionController::Flash
include ActionController::RequestForgeryProtection
include ActionController::MimeResponds
include ActionController::HttpAuthentication::Basic::ControllerMethods
include ActionView::Layouts
end
In config/initializers/rails_admin.rb
RailsAdmin.config do |config|
# other config stuff ...
config.parent_controller = '::RailsAdminCustomController'
end
Just check the RailsAdmin::ApplicationController
here, and the config settings here.
You should have a json view file in this location bookings/index.json.jbuilder And inside this file something like
bookings/index.json.jbuilder
json.name @bookings.name
json.date @bookings.date
This is another template missing
application/index
but really don't know you app completely. So maybe that's the application layout you implemented using ActionView::Layouts. In that case is asking you to implement a layout page file in the location application/index.
NOTE: Those two file inside the views folder.
As of v1.0.0
(released September 2016), Rails Admin now supports Rails 5 API-mode straight out-of-the-box. The gem itself injects the missing middleware to render its views and there is no extra configuration required.
Links: