Skip to content

Instantly share code, notes, and snippets.

View naofumi's full-sized avatar

Naofumi Kagami naofumi

View GitHub Profile
import {Controller} from "@hotwired/stimulus"
/*
* PermanentAttribute Controller
*
* This prevents Turbo morphing from updating certain attributes on an element.
* It is especially useful if you have changed a class on the browser in response
* to a UI event without sending this change to the server. The server does not
* know about this change and so will send the browser the original class on morphing,
* thereby clearing the state introduced by the original UI event.
@naofumi
naofumi / form_object.rb
Last active October 16, 2023 16:25
Delegation-based implementation of Rails FormObjects
class AdminUsers::RegistrationForm
include ActiveModel::Model
attr_accessor :object
validates :first_name, :last_name, :email, presence: true
delegate :first_name, :first_name=,
:last_name, :last_name=,
:email, :email=,
:password, :password=,
@naofumi
naofumi / rails http status codes
Created December 19, 2021 13:59 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing