json-typed-attributes
Installation
SKILL.md
JSON Typed Attributes
This skill helps you work with JSON-backed attributes in Rails models using the StoreJsonAttributes concern. It provides type casting, validation support, and seamless form integration.
When to Use
- You need flexible data storage without creating separate database columns
- You want to store structured data (like configuration, metadata, or dynamic fields) in a JSON column
- You need proper type casting for JSON attributes (numbers, dates, booleans, arrays)
- You want to validate JSON-backed attributes like regular ActiveRecord attributes
- You need JSON attributes to work seamlessly with Rails forms
Setup
1. Ensure JSON Column Exists
Your model must have a JSON column to store the attributes. Common names are data, metadata, or settings: