Recourse

Getting started

Install the gem

# Gemfile
gem 'recourse'

Nothing else goes in the host. Turbo comes as a dependency, and everything a page is styled and scripted by is served by bh, another dependency, so nothing is fetched across a network.

Route a resource

# config/routes.rb
- resources :posts, only: %i[index show] do
+ recourses :posts, only: %i[index show] do
-   resources :comments, except: :destroy
+   recourses :comments, except: :destroy
  end

recourses takes everything resources takes. It draws the same routes, then supplies whatever the host lacks: a PostsController where none is defined, and a template for every action. A controller or a template the app already has is left alone. A name with no model behind it raises while the routes draw.

What each action earns

RoutedEarns
indexA sidebar entry, a keyboard shortcut, and a paginated, searchable, sortable, filterable table.
showA record’s page, every value drawn as what it is, encrypted ones masked.
new, editA form with a field per column, carrying what the validators say.
create, updateThe write, a toast naming the record, and the row it landed on marked.
destroyA button that names what goes with the record before it goes.

Every resource with an index is an entry in the sidebar, in routes order, answering to a letter of its title held with Option. Nested resources default to only: %i[index new create].

Secure the controllers

# app/controllers/recourses_controller.rb
class RecoursesController < Recourse::BaseController
  before_action :authenticate!
end

Every controller the gem defines inherits this class, and so does any the host writes for one resource, so one guard stands above every screen.