store-model-advanced-patterns

Wrap JSON-backed database columns with ActiveModel-like StoreModel classes.

47|11|Updated Nov 26, 2025
One-click install
npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill store-model-advanced-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: store-model-advanced-patterns
Source: https://github.com/majesticlabs-dev/majestic-marketplace/tree/main/plugins/majestic-rails/skills/store-model-coder/references/advanced-patterns.md
Command: npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill store-model-advanced-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This reference covers advanced patterns for StoreModel including nested types, one-of types, and array handling.

Core Features & Use Cases

  • Nested Models: Complex nested attributes with validation.
  • One-Of Types: Polymorphic JSON structures.
  • Parent Tracking: Optional parent linking and tracking.

Quick Start

Demonstrate a nested Address object within a parent Model with proper error merging.

Frequently Asked Questions about store-model-advanced-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle nested JSON attributes with validations in Rails models?

StoreModel wraps JSON-backed database columns with ActiveModel-like classes, enabling nested models with full validation support. Define nested Address or similar objects within parent models, and validations cascade automatically with proper error merging.

What's the best way to store polymorphic JSON structures in a single database column?

One-of types in StoreModel let you define multiple valid JSON schemas for a single column. The schema validates incoming data against the matching type, enforcing type safety and clean polymorphic behavior without separate tables.

Can I track parent-child relationships within JSON-stored models?

StoreModel supports optional parent linking and tracking, allowing child models to reference their parent. This enables bidirectional access and maintains relationship context within nested JSON structures.

How do I apply ActiveModel validations and dirty tracking to JSON data?

StoreModel applies full ActiveModel behavior to JSON attributes including validations, enums, array handling, and change tracking. JSON data gains type safety and Rails integration through to_type, to_array_type, and one_of type definitions.

Do I need separate tables to manage complex nested JSON configurations?

No. StoreModel handles complex nested attributes, arrays, and validations within a single JSON column. Configuration objects and multi-level nested data can coexist with type safety and validation, eliminating table proliferation.

What happens when validations fail on nested StoreModel attributes?

Errors from nested models merge into the parent's error collection, preserving the full validation context. This lets you display and handle validation feedback across the entire object hierarchy as a single unit.