Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Ruby
  3. ActiveAttr

ActiveAttr

MITRuby

A Ruby gem providing ActiveModel-like functionality for plain Ruby objects, including attributes, typecasting, mass assignment, and serialization.

GitHubGitHub
1.2k stars91 forks0 contributors

What is ActiveAttr?

ActiveAttr is a Ruby gem that extends plain Ruby objects with ActiveModel-like features such as attribute definitions, typecasting, mass assignment, and serialization. It solves the problem of needing ORM-like functionality without the complexity of ActiveRecord or full ActiveModel, making it ideal for lightweight model layers in non-Rails applications or as a supplement to existing models.

Target Audience

Ruby developers building plain Ruby objects that require structured attributes, type safety, and ActiveModel compatibility, especially in non-Rails projects or when avoiding full ORM overhead.

Value Proposition

Developers choose ActiveAttr for its modularity and simplicity—it provides just the ActiveModel features needed without bloat, integrates seamlessly with Rails when desired, and offers a clean DSL for attribute management.

Overview

What ActiveModel left out

Use Cases

Best For

  • Adding attribute management to plain Ruby objects
  • Building lightweight models without ActiveRecord
  • Implementing type-safe attributes with automatic conversion
  • Enabling mass assignment with security in non-Rails apps
  • Creating ActiveModel-compatible models for use with Rails tools
  • Testing models with integrated RSpec matchers

Not Ideal For

  • Applications requiring full database persistence with ActiveRecord associations and queries
  • Rails projects already using ActiveModel extensively where ActiveAttr adds redundant overhead
  • Teams needing out-of-the-box validations and callbacks without additional ActiveModel includes
  • Scenarios where zero-dependency, minimal plain Ruby objects are preferred over gem-based solutions

Pros & Cons

Pros

Modular Design

Allows selective inclusion of only needed modules like Attributes or MassAssignment, keeping models lightweight and focused, as shown in the README's composable examples.

Type Safety

TypecastedAttributes enable automatic conversion (e.g., string to integer) with a clean DSL, reducing boilerplate code for attribute handling.

Security Integration

MassAssignment supports Rails security features like strong parameters and protected attributes, ensuring safe bulk updates in both Rails and non-Rails apps.

Rails Compatibility

Automatically configures with Rails logger and integrates with Rails tools, making it seamless for hybrid or non-Rails projects needing ActiveModel-like behavior.

Cons

Limited ActiveModel Compliance

BasicModel only meets minimum API requirements; advanced features like validations require additional ActiveModel includes, adding complexity.

Setup Verbosity

Security features need manual inclusion of multiple modules (e.g., ForbiddenAttributesProtection), which can be error-prone and increase setup time.

Ecosystem Constraints

Lacks built-in support for nested attributes or associations, forcing developers to implement these manually or rely on other gems.

Frequently Asked Questions

Quick Stats

Stars1,197
Forks91
Contributors0
Open Issues42
Last commit2 months ago
CreatedSince 2011

Tags

#orm#rails#model-layer#activemodel#serialization#models#ruby

Built With

R
Ruby

Included in

Ruby14.1k
Auto-fetched 5 hours ago

Related Projects

VirtusVirtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects

Stars3,748
Forks228
Last commit4 years ago
HashieHashie

Hashie is a collection of classes and mixins that make Ruby hashes more powerful.

Stars3,025
Forks312
Last commit2 months ago
HamsterHamster

Efficient, Immutable, Thread-Safe Collection classes for Ruby

Stars1,923
Forks92
Last commit4 years ago
AddressableAddressable

Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. It is flexible, offers heuristic parsing, and additionally provides extensive support for IRIs and URI templates.

Stars1,598
Forks279
Last commit20 hours ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub