All Projects → blocknotes → activeadmin_active_resource

blocknotes / activeadmin_active_resource

Licence: MIT License
Active Admin + Active Resource: to use a REST API in place of a local database as data source

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
SCSS
7915 projects

Projects that are alternatives of or similar to activeadmin active resource

activeadmin medium editor
Medium Editor for ActiveAdmin
Stars: ✭ 26 (+30%)
Mutual labels:  activeadmin, ruby-on-rails, activeadmin-plugin
Activeadmin froala editor
Froala WYSIWYG editor for ActiveAdmin
Stars: ✭ 30 (+50%)
Mutual labels:  activeadmin, rails5, ruby-on-rails
Reactchat
A chat app built with React.js and ActionCable in Ruby on Rails 5.1
Stars: ✭ 90 (+350%)
Mutual labels:  rails5, ruby-on-rails
Websiteone
A website for Agile Ventures
Stars: ✭ 132 (+560%)
Mutual labels:  rails5, ruby-on-rails
Activeadmin trumbowyg
Trumbowyg Editor for ActiveAdmin
Stars: ✭ 29 (+45%)
Mutual labels:  activeadmin, rails5
Dashvis
An open-source Dashboard built for users, to organize their resources via Tables and Folders.
Stars: ✭ 31 (+55%)
Mutual labels:  rails5, ruby-on-rails
katapult
Kickstart Rails development!
Stars: ✭ 21 (+5%)
Mutual labels:  rails5, ruby-on-rails
rails-rest-api
A simple RoR 5 REST API demo with JWT authentication.
Stars: ✭ 25 (+25%)
Mutual labels:  rails5, ruby-on-rails
Activeadmin quill editor
Quill Rich Text Editor for ActiveAdmin
Stars: ✭ 76 (+280%)
Mutual labels:  activeadmin, rails5
Activeadmin dynamic fields
ActiveAdmin plugin to add dynamic behaviors to fields
Stars: ✭ 73 (+265%)
Mutual labels:  activeadmin, rails5
Activeadmin blaze theme
ActiveAdmin theme based on Blaze CSS toolkit
Stars: ✭ 35 (+75%)
Mutual labels:  activeadmin, rails5
active admin role
Role based authorization with CanCanCan for Active Admin
Stars: ✭ 53 (+165%)
Mutual labels:  activeadmin, activeadmin-plugin
LocalSupport
A directory of local support services and volunteer opportunities
Stars: ✭ 60 (+200%)
Mutual labels:  rails5, ruby-on-rails
ror-capstone
Ruby on Rails app to track activities and assign a group to them
Stars: ✭ 15 (-25%)
Mutual labels:  ruby-on-rails
circulate
An operating system for lending libraries
Stars: ✭ 51 (+155%)
Mutual labels:  ruby-on-rails
ohloh-ui
Web Application for the Ohloh Stack.
Stars: ✭ 72 (+260%)
Mutual labels:  ruby-on-rails
plug rails cookie session store
Rails compatible Plug session store
Stars: ✭ 93 (+365%)
Mutual labels:  ruby-on-rails
envkey-ruby
EnvKey's official Ruby client library
Stars: ✭ 24 (+20%)
Mutual labels:  ruby-on-rails
BlogArticle
My known and what i learning
Stars: ✭ 41 (+105%)
Mutual labels:  ruby-on-rails
rails-microservices-book
A guide to building distributed Ruby on Rails applications using Protocol Buffers, NATS and RabbitMQ
Stars: ✭ 23 (+15%)
Mutual labels:  rails5

Active Admin + Active Resource

gem version gem downloads linters specs

An Active Admin plugin to use a REST API data source in place of a local database using Active Resource.

NOTICE: currently some Active Admin features don't work as expected:

  • Filters are partially supported (see example)
  • Some form fields must be configured explicitly (like the associations)
  • Comments are not supported

Please if you like it.

Install

  • Add to your project's Gemfile (with Active Admin installed): gem 'activeadmin_active_resource'
  • Execute bundle
  • Disable comments in Active Admin config initializer (config.comments = false)

Examples

Please take a look at the examples folder:

  • a Rails6 application with Active Admin and this component, see here;
  • a Rails6 API application used as data source, see here.

For another example check the specs.

Basic instructions:

  • Post model:
class Post < ActiveResource::Base
  self.site = 'http://localhost:3000'  # API url: another Rails project, a REST API, etc.

  self.schema = {  # Fields must be declared explicitly
    id: :integer,
    title: :string,
    description: :text,
    author_id: :integer,
    category: :string,
    dt: :datetime,
    position: :float,
    published: :boolean,
    created_at: :datetime,
    updated_at: :datetime,
  }
end
  • Post admin config:
ActiveAdmin.register Post do
  filter :title_cont  # Ransack postfixes required (_eq, _cont, etc.)

  controller do
    def permitted_params
      params.permit!  # Permit all just for testing
    end
  end

  form do |f|
    f.inputs do
      f.input :id, as: :hidden unless f.object.new_record?  # Required
      f.input :title
      # ... other fields
    end
    f.actions
  end
end
  • Ransack options here
  • Rails API index example with Ransack and Kaminari:
  after_action :set_pagination, only: [:index]

  def index
    per_page = params[:per_page].to_i
    per_page = 15 if per_page < 1
    @posts = Post.ransack( params[:q] ).result.order( params[:order] ).page( params[:page].to_i ).per( per_page )
  end

  def set_pagination
    headers['Pagination-Limit'] = @posts.limit_value.to_s
    headers['Pagination-Offset'] = @posts.offset_value.to_s
    headers['Pagination-TotalCount'] = @posts.total_count.to_s
  end

Notes

If you create a new rails project don't use --skip-active-record.

Do you like it? Star it!

If you use this component just star it. A developer is more motivated to improve a project when there is some interest. My other Active Admin components.

Or consider offering me a coffee, it's a small thing but it is greatly appreciated: about me.

Contributors

License

The gem is available as open-source under the terms of the MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].