Skip to content

Instantly share code, notes, and snippets.

Yes, it is possible to create a custom form in Active Admin without using an ActiveRecord database model. Active Admin is built on top of the Rails framework, and while it is primarily designed to work with ActiveRecord models, you can still create custom forms and interact with non-ActiveRecord models or even external APIs.

Here’s how you can achieve this:


Steps to Create a Custom Form in Active Admin Without ActiveRecord:

  1. Define a Plain Ruby Class (Model): Create a plain Ruby class that represents your custom model. This class does not need to inherit from ActiveRecord::Base. You can use ActiveModel::Model to include basic model behavior like validations and form handling.
@philiplambok
philiplambok / Gemfile
Created December 17, 2023 12:07
Rack Mini Profiler
group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
gem "rack-mini-profiler"
gem "memory_profiler"
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
{
"transaction_attachment": {
"id": 118630,
"transaction_id": 2849716,
"file": {
"url": "https://jurnal-quickbook-dev.jurnal.id/uploads/transaction_attachment/file/118630/Screen_Shot_2023-09-21_at_10.30.04.png"
},
"created_at": "2023-09-21T08:59:46.434Z",
"updated_at": "2023-09-21T08:59:46.434Z",
"transaction_token": "RbnVvP8gd-92Ud532jp0zg",

Name: [Your Name] Contact Information:

  • Phone number: [Your phone number]
  • Email address: [Your email address]
  • LinkedIn: [Your LinkedIn profile URL, if applicable]

Summary: Experienced secondary school teacher with a passion for creating an inclusive and engaging learning environment for all students. Adept at using technology to enhance the curriculum and tailoring instruction to meet the unique needs of each student. Strong ability to communicate with students, parents, and colleagues, and to build positive relationships with all stakeholders.

Education:

{
"editor.fontFamily": "Comic Mono, Roboto Mono, Jetbrains Mono, IBM Plex Mono, Dank Mono, Menlo, Monaco, 'Courier New', monospace",
"workbench.editor.showTabs": false,
"workbench.statusBar.visible": false,
"editor.minimap.enabled": false,
"editor.tabSize": 2,
// For Stylelint
// "stylelint.autoFixOnSave": false,
"workbench.colorCustomizations": {
"terminal.ansiBrightCyan": "#EE64AE",
@philiplambok
philiplambok / specs.yaml
Created October 23, 2022 15:44
Learn Open API 3.0
openapi: 3.0.0
info:
version: 1.0.0
title: P & T Kitchen
description: The payment gateway that you don't hate.
servers:
- url: https://api.kitchen.com/api/v1
- url: https://staging-api.kitchen.com/api/v1
@philiplambok
philiplambok / go-methods.go
Created September 18, 2022 07:29
go methods
package main
import "fmt"
type Person struct {
FirstName string
LastName string
}
func (p Person) fullName() string {
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
words := strings.Split(s, " ")
var count int
@philiplambok
philiplambok / compound-interest.rb
Last active September 7, 2022 02:16
compound-interest Neo Bank VS SSF
# only runnable inside Rails web application
include ActionView::Helpers::NumberHelper
def to_idr(amount)
number_to_currency(amount, unit: 'Rp.', precision: 3)
end
def noebank
net_worth = 0
emergency_fund = 30_000_000
{
"editor.fontFamily": "Comic Mono, IBM Plex Mono, Jetbrains Mono, Dank Mono, Menlo, Monaco, 'Courier New', monospace",
"workbench.iconTheme": "vscode-icons",
"workbench.editor.showTabs": false,
"workbench.statusBar.visible": false,
"editor.minimap.enabled": false,
"editor.tabSize": 2,
// "plantuml.server": "https://www.plantuml.com",
// "plantuml.render": "PlantUMLServer",
// "ruby.useLanguageServer": true,