Add Custom Resourcesful Controller
This document outlines how to add custom resourcesful controller:
Assume that:
- Wallaby is mounted at
/admin - ActiveRecord model is
Product
To add custom resourcesful controller Admin::CustomProductsController, the steps are:
Create the routes in
config/routes.rb:Rails.application.routes.draw do wallaby_mount at: '/admin' do resources :custom_products end endCreate a custom controller inheriting from the admin interface application controller as
app/controllers/admin/custom_products_controller.rb:class Admin::CustomProductsController < Admin::ApplicationController endNOTE:
Admin::ApplicationControllercan be replaced withWallaby::ResourcesControllerif it doesn’t exist.Tell controller that its model class is
Productif Wallaby doesn’t know which model class to use for this controller:class Admin::CustomProductsController < Admin::ApplicationController self.model_class = Product end