CtrlK
BlogDocsLog inGet started
Tessl Logo

igmarin/hanakai-yaku

Curated library of atomic AI agent skills for Hanami, dry-rb, and ROM Ruby development. Covers actions, slices, repositories, relations, changesets, providers, DI, operations, TDD, CLI, views, routing, and validation. Shared Ruby process skills have moved to ruby-core-skills. Uses Markdown + Front-matter architecture.

92

1.33x
Quality

94%

Does it follow best practices?

Impact

92%

1.33x

Average score across 35 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

RELATIONS.mdskills/db/define-relation/

ROM Relations Associations & Advanced Queries

This document details database relations, associations, and custom queries in Hanami 2.x using rom-rb.


Defining Associations

Relations declare how different tables link to one another. Use these association macros:

# app/relations/posts.rb
module MyApp
  module Relations
    class Posts < Hanami::DB::Relation
      schema :posts, infer: true do
        # belongs_to relationship
        associations do
          many_to_one :users, as: :author
        end
      end
    end
  end
end
# app/relations/users.rb
module MyApp
  module Relations
    class Users < Hanami::DB::Relation
      schema :users, infer: true do
        # has_many relationship
        associations do
          one_to_many :posts, as: :posts
        end
      end
    end
  end
end

Advanced Custom Queries

Custom queries are defined directly as public methods in the Relation class. Use standard Sequel query builder patterns (like where, order, select):

class Users < Hanami::DB::Relation
  schema :users, infer: true

  # Reusable active scope filter
  def active
    where(status: "active")
  end

  # Lookup filter by attribute
  def by_email(email)
    where(email: email)
  end

  # Sorting query
  def newest
    order { created_at.desc }
  end
end

skills

README.md

tile.json