๐Ÿง  ActiveBuddy โ€“ AI-assisted Model Validator for Rails

ActiveBuddy is a professional-grade Ruby gem that intelligently analyzes your ActiveRecord models and suggests validations and associations based on column names, data types, constraints, and naming conventions.

Perfect for jump-starting new Rails projects with smart, conventional best-practice validations.


๐ŸŽฏ Features

  • โœ… Smart inference of:
    • presence
    • uniqueness
    • length
    • numericality
    • format validations
  • ๐Ÿงฉ Association recommendations:
    • belongs_to, has_many, etc.
  • ๐Ÿ” Custom rule engine based on Rails conventions and common model types (User, Payment, Account, etc.)
  • ๐Ÿ”ฎ Expandable AI-based ruleset planned for future updates

๐Ÿ›  Installation

Add this line to your application's Gemfile:

gem 'active_buddy'

And then execute:

bundle install

Or install it yourself as a standalone gem:

gem install active_buddy

โšก๏ธ Usage

In your Rails app or console:

require 'active_Buddy'

analyzer = ActiveBuddy::Analyzer.new(User)
puts analyzer.suggest_validations
puts analyzer.suggest_associations
puts analyzer.quick_audit

Output:

validates :email, presence: true
validates :email, uniqueness: true
validates :email, format: { with: /\A[^@\s]+@[^@\s]+\.[^@\s]+\z/ }
validates :name, presence: true
belongs_to :account

โœ… Supported Patterns

ActiveBuddy automatically picks up and suggests validations based on:

Field Pattern Suggested Validations
email format, presence, uniqueness
phone, mobile phone format
name, title presence, length
password length (>= 6)
age, count, qty numericality (integer)
price, amount numericality (>= 0)
bio, description length (max 1000)
status, role, type presence

Also detects and formats associations from ActiveRecord relationships.

๐Ÿ” Auditing model: User Fields detected: id, email, password, account_id, created_at, updated_at

โœ… Suggested Validations: validates :email, presence: true validates :email, uniqueness: true

๐Ÿ”— Suggested Associations: belongs_to :account

๐Ÿ’ก Tips:

  • Consider adding presence validations for key fields.
  • Add associations if your model connects to others (like belongs_to, has_many).

๐Ÿงช Run Specs

bundle exec rspec