百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

hydra_attribute

> 编程语言
开源

为 ActiveRecord 模型实现 EAV 模式

181 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

为 ActiveRecord 模型实现 EAV 模式

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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

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