This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddCountOnHandToVariantsAndProducts < ActiveRecord::Migration | |
def self.up | |
add_column :variants, :count_on_hand, :integer, :default => 0, :null => false | |
add_column :products, :count_on_hand, :integer, :default => 0, :null => false | |
Variant.class_eval do | |
def on_hand=(new_level) | |
delta_units = new_level.to_i - on_hand.to_i | |
# increase Inventory when positive delta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
module NestedAttributes #:nodoc: | |
module ClassMethods | |
# Defines an attributes writer for the specified association(s). If you | |
# are using <tt>attr_protected</tt> or <tt>attr_accessible</tt>, then you | |
# will need to add the attribute writer to the allowed list. | |
# | |
# Supported options: | |
# [:allow_destroy] | |
# If true, destroys any members from the attributes hash with a |
NewerOlder