8000 GitHub - skaczor/custom_attributes: Plugin to define and use custom attributes for a model
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

skaczor/custom_attributes

Repository files navigation

Permits managing custom attributes for Active Record models. Unlike other plugins,
custom_attributes uses an associated model to define which columns should be
available for the current model.

For example, suppose that you have a catalog of items for sale (Item model),
such as Monitors, Hard Disks, etc. Each item needs attributes that are specific
only for its category (Category Model). Therefore, let's define that Monitors
should have the display_size and dpi attributes, while Hard Disks should define
capacity and rpm.

class Category < ActiveRecord::Base
  include Customizable
  defines_custom_columns
end

class Item < ActiveRecord::Base
  belongs_to :category

  include Customizable
  has_custom_attributes_based_on(:category)
end

The plugin will automatically create the required attributes for each Item model,
based on its association with the Category model.

About

Plugin to define and use custom attributes for a model

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0