Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

hydra_attribute

> 编程语言
Open source

Implementation of EAV pattern for ActiveRecord models

181 stars0 likes1 views
WebsiteGitHub

About

Implementation of EAV pattern for ActiveRecord models

Looking for contributors

Unfortunately, I don't have enough time to work on this gem now. If you feel you can contribute to it, please, reach me via email, and I'll grant permissions to this project.

hydra_attribute

Demo | Wiki | RDoc

hydra_attribute is an implementation of EAV (Entity-Attribute-Value) pattern for ActiveRecord models. It allows to create or remove attributes in runtime. Also each record may have different sets of attributes, for example: Product with ID 1 can have different set of attributes than Product with ID 2.

Notice

Until the first major version is released:

  • each new minor version doesn't guarantee back compatibility with previous one

Requirements

  • ruby >= 1.9.2
  • active_record >= 3.2

Installation

Add the following line to Gemfile:

ruby
gem 'hydra_attribute'
# or for rails 4
# gem 'hydra_attribute', github: 'kostyantyn/hydra_attribute', branch: 'rails4'
# or for rails 4.1
# gem 'hydra_attribute', github: 'kostyantyn/hydra_attribute', branch: 'rails4.1'

and run bundle install from your shell.

Then we should generate our migration:

bash
rails generate migration create_hydra_attributes

The content should be:

ruby
class CreateHydraAttributeTables 1, "green"=>3, "red"=>1}

Wiki Docs

  • Create migration
  • Create attributes in runtime
  • Create sets of attributes
  • Query methods
  • Database schema
  • Helper methods
  • Migrate from 0.3.2 to 0.4.0

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言