0

Is there a way to access the data from Active Admin? Im creating a mobile app that will connect to an active admin website. I need to retrieve data from the website.

1 Answer 1

0

We are using "active_model_serializers" gem for this. To make it work just:

  1. Add active_model_serializers to your Gemfile
  2. Add the following to config/initializers/active_admin.rb
ActiveAdmin::ResourceController.class_eval do
  before_action { self.namespace_for_serializer = ::Admin }
end
  1. Put your serializers into app/serializers/admin/ folder
# app/serializers/admin/user_serializer.rb
module Admin
  class UserSerializer < ::ActiveModel::Serializer
    attributes :id, :username
  end
end

And that's it. Now you should be able to make requests with JSON format to your ActiveAdmin endpoints.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.