Using Administrate with an API app
Created by: lesliev
I know the docs say to set config.api_only = false
in config/application.rb
but for those that want to keep API mode turned on, I was able to get Administrate
to properly add and update records with the following workarounds:
- Add these to
config/application.rb
# Enable Flash, Cookies, MethodOverride for Administrate Gem
config.middleware.use ActionDispatch::Flash
config.session_store :cookie_store
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore, config.session_options
config.middleware.use ::Rack::MethodOverride
- Make sure routes in
routes.rb
generate routes for all 7 controller actions. Example:
namespace :admin do
%i(
attachments
assets
posts
).each do |name|
resources name, only: %i(index show new create edit update destroy)
end