Skip to content

Instantly share code, notes, and snippets.

@edzhelyov
Created September 26, 2011 13:54
Show Gist options
  • Save edzhelyov/1242280 to your computer and use it in GitHub Desktop.
Save edzhelyov/1242280 to your computer and use it in GitHub Desktop.
Product initialization
class Product < ActiveRecord::Base
belongs_to :product_type
has_many :product_attributes, :extend => FindersByAtrributeName
def initialize(attributes = nil)
super
define_dynamic_accessors
end
def define_dynamic_accessors
product_type.dynamic_attributes.each do |attr|
define_dynamic_writer(attr.name)
define_dynamic_reader(attr.name)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment