store-model-coder

Wrap JSON-backed database columns with StoreModel classes for type safety and validations.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill shows how to wrap JSON-backed database columns with StoreModel, enabling typed attributes, validations, and nested structures.

Core Features & Use Cases

  • StoreModel Basics: Define JSON-backed attributes with type safety.
  • Nested Models: Compose nested structures with validations.
  • Merging & Errors: Manage nested errors and validations across parent models.

Quick Start

Define a Configuration value object and assign it to a Product model to demonstrate nested attributes and validation.

Frequently Asked Questions about store-model-coder

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

FAQPage Schema
How do I add type safety and validations to JSON columns in Rails?

StoreModel wraps JSON-backed database columns with ActiveModel-like classes, providing type safety, validations, and clean separation of concerns. Define attributes with types and validations, then assign instances to your model's JSON columns to get validation errors and nested attribute support automatically.

Can I nest models and arrays within JSON attributes in Rails?

Yes. StoreModel supports nested models, arrays of models, and composed structures within JSON columns. Define child models with their own validations and attributes, then compose them in parent models using to_type and to_array_type patterns for full nested validation and error merging.

How do I handle validation errors across nested JSON attributes?

StoreModel merges validation errors from nested models into the parent model's error set. When validations fail on child attributes, errors surface at the parent level, allowing you to display and handle them as a unified validation result.

What database considerations apply when storing typed JSON in Rails?

Store JSON in jsonb or json columns depending on your database. JSONB supports indexing and queries; json stores raw text. Consider migration strategy, index requirements for filtering on nested attributes, and how StoreModel's patterns interact with your schema design.

Do I need ActiveModel knowledge to use JSON-backed typed attributes?

Familiarity with ActiveModel validations and attribute definitions helps, but StoreModel mimics ActiveModel's API closely. If you know Rails models and validations, the JSON wrapper syntax follows the same patterns with minimal learning curve.

How does StoreModel handle attributes not defined in the schema?

StoreModel provides unknown-attribute handling to control whether extra JSON keys are allowed, rejected, or logged. Configure this behavior per model to enforce strict schemas or permit flexible JSON payloads alongside your defined typed attributes.