Module: ActiveRecord::Acts::EavModel::InstanceMethods::ClassMethods
- Defined in:
- lib/acts_as_eav_model.rb
Instance Method Summary collapse
-
#create_attribute_table(options = {}) ⇒ Object
Rake migration task to create the versioned table using options passed to has_eav_behavior.
-
#drop_attribute_table(options = {}) ⇒ Object
Rake migration task to drop the attribute table.
Instance Method Details
#create_attribute_table(options = {}) ⇒ Object
Rake migration task to create the versioned table using options passed to has_eav_behavior
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/acts_as_eav_model.rb', line 297 def create_attribute_table( = {}) .keys.each do |key| continue if [key][:parent] != self.name model = [key][:class_name] return if connection.tables.include?([model][:table_name]) self.connection.create_table([model][:table_name], ) do |t| t.integer [model][:foreign_key], :null => false t.string [model][:name_field], :null => false t.string [model][:value_field], :null => false t. end self.connection.add_index [model][:table_name], [model][:foreign_key] end end |
#drop_attribute_table(options = {}) ⇒ Object
Rake migration task to drop the attribute table
320 321 322 323 324 325 326 327 |
# File 'lib/acts_as_eav_model.rb', line 320 def drop_attribute_table( = {}) .keys.each do |key| continue if [key][:parent] != self.name model = [key][:class_name] self.connection.drop_table [model][:table_name] end end |