Add a Non-resourcesful Action
This document outlines how to add a non-resourcesful action e.g. export:
Assume that:
- Wallaby is mounted at
/admin - ActiveRecord model is
Product
To add a non-resourcesful action export, the steps are:
Create the routes in
config/routes.rb:Rails.application.routes.draw do wallaby_mount at: '/admin' do resources :products do get :export, on: :collection end end endCreate a custom controller inheriting from the admin interface application controller as
app/controllers/admin/products_controller.rb:class Admin::ProductsController < Admin::ApplicationController endNOTE:
Admin::ApplicationControllercan be replaced withWallaby::ResourcesControllerif it doesn’t exist.Create the action method
export:class Admin::ProductsController < Admin::ApplicationController def export # do something end endAdd the export link to a proper place in the page.