Skip to content
PLAY VIDEO PLAY VIDEO PLAY VIDEO
By Tianwen Chen

Wallaby: a newcomer in the admin interface market

Are you struggling to choose between ActiveAdmin and Rails Admin? Just to confuse you further, there is now a third option:

Wallaby

So, apart from an admin interface, what is Wallaby? The core design is that:

  • It uses the decorator to store the customisation information for an ActiveRecord model.
  • It can be customised in a pure Rails way using controllers and views.

How does this work exactly? A piece of code is worth a thousand words! To illustrate, let's use the following ActiveRecord model:

#! app/models/product.rb
class Product < ActiveRecord::Base
  has_one :picture, as: :imageable
  has_many :order_items, class_name: Order::Item.name
  has_many :orders, through: :order_items
  belongs_to :category
  has_and_belongs_to_many :tags

  scope :featured, -> { where(featured: true) }
end

Before we make any changes, let's take a look at the show page:

wallaby - products - before

Now, here comes the customisation:

  • The code snippet below updates the show pages to display only the preview and order fields. preview is a custom field with a custom markdown type.

    #! app/decorators/product_decorator.rb
    class ProductDecorator < Wallaby::ResourceDecorator
      self.show_fields[:preview] = { type: 'markdown', label: 'preview' }
      self.show_field_names = %w( preview orders )
    
      def preview
        "# #{name} - #{sku}\n#{description}"
      end
    end
    
  • To make preview display as custom type markdown, we need to create a type partial as follows:

    <% #! app/views/admin/products/show/_markdown.html.erb %>
    <% markdowner = Redcarpet::Markdown.new(Redcarpet::Render::HTML, {}) %>
    <%= raw markdowner.render value %>
    
  • The following customisation displays a pinned message at the top of show page. It doesn't directly relate to the above example, but it does illustrate how things can be customised at the controller level.

    #! app/controllers/admin/products_controller
    module Admin
      class ProductsController < Wallaby::ResourcesController
        def show
          flash[:warning] ||= "Product import will happen after business hours tonight."
          super
        end
      end
    end
    

Then the show page will become:

wallaby - products - after

The above codes are not the best example, but they make my point. Too simple to believe, isn't it?

Moreover, Wallaby has a lot to offer:

  • It handles all ActiveRecord associations, including polymorphism.
  • It supports Single Table Inheritance (STI)
  • Predefine filters to allow user to easily access the custom query
  • Advanced colon search, e.g., ordered_at:>2017-07-01 name_start_with:^tian
  • User-friendly and responsive UI

Making a great admin interface using Wallaby is just a beginning. Find out more here.

Latest Articles by Our Team

Our expert team of designers and developers love what the do and enjoy sharing their knowledge with the world.

We Hire Only the Best

reinteractive is Australia’s largest dedicated Ruby on Rails development company. We don’t cut corners and we know what we are doing.

We are an organisation made up of amazing individuals and we take pride in our team. We are 100% remote work enabling us to choose the best talent no matter which part of the country they live in. reinteractive is dedicated to making it a great place for any developer to work.

Free Community Workshops

We created the Ruby on Rails InstallFest and Ruby on Rails Development Hub to help introduce new people to software development and to help existing developers hone their skills. These workshops provide invaluable mentorship to train developers, addressing key skills shortages in the industry. Software development is a great career choice for all ages and these events help you get started and skilled up.

  • Webinars

    Webinars

    Webinars are our online portal for tips, tricks and lessons learned in everything we do. Make the most of this free resource to help you become a better developer.

    Learn more about webinars

  • Installfest

    Installfest

    The Ruby on Rails Installfest includes a full setup of your development environment and step-by-step instructions on how to build your first app hosted on Heroku. Over 1,800 attendees to date and counting.

    Learn more about Installfest

  • Development Hub

    Development Hub

    The Ruby on Rails Development Hub is a monthly event where you will get the chance to spend time with our team and others in the community to improve and hone your Ruby on Rails skills.

    Learn more about Development Hub

Get the “reinteractive Review” Monthly Email