#
# Storage Method update event. This event records the current operations for a BPT asset
#
class StorageMethodUpdateEvent < AssetEvent
      
  # Callbacks
  after_initialize :set_defaults
      
  # Associations  
  belongs_to  :vehicle_storage_method_type
      
  # Validations
  validates                 :vehicle_storage_method_type_id,  :presence => true
      
  #------------------------------------------------------------------------------
  # Scopes
  #------------------------------------------------------------------------------
  # set the default scope
  default_scope { where(:asset_event_type_id => AssetEventType.find_by_class_name(self.name).id).order(:event_date) }
    
  # List of hash parameters allowed by the controller
  FORM_PARAMS = [
    :vehicle_storage_method_type_id
  ]
  
  #------------------------------------------------------------------------------
  #
  # Class Methods
  #
  #------------------------------------------------------------------------------

  def self.allowable_params
    FORM_PARAMS
  end
    
  #returns the asset event type for this type of event
  def self.asset_event_type
    AssetEventType.find_by_class_name(self.name)
  end

  #------------------------------------------------------------------------------
  #
  # Instance Methods
  #
  #------------------------------------------------------------------------------
        

  # This must be overriden otherwise a stack error will occur  
  def get_update
    vehicle_storage_method_type unless vehicle_storage_method_type.nil?
  end

  protected

  # Set resonable defaults for a new condition update event
  def set_defaults
    super
    self.vehicle_storage_method_type ||= asset.vehicle_storage_method_type
    self.asset_event_type ||= AssetEventType.find_by_class_name(self.name)
  end    
  
end

#
# Storage Method update event. This event records the current operations for a BPT asset
#
class StorageMethodUpdateEvent < AssetEvent
      
  # Callbacks
  after_initialize :set_defaults
      
  # Associations  
  belongs_to  :vehicle_storage_method_type
      
  # Validations
  validates :vehicle_storage_method_type,  :presence => true
      
  #------------------------------------------------------------------------------
  # Scopes
  #------------------------------------------------------------------------------
  # set the default scope
  default_scope { where(:asset_event_type_id => AssetEventType.find_by_class_name(self.name).id).order(:event_date) }
    
  # List of hash parameters allowed by the controller
  FORM_PARAMS = [
    :vehicle_storage_method_type_id
  ]
  
  #------------------------------------------------------------------------------
  #
  # Class Methods
  #
  #------------------------------------------------------------------------------

  def self.allowable_params
    FORM_PARAMS
  end
    
  #returns the asset event type for this type of event
  def self.asset_event_type
    AssetEventType.find_by_class_name(self.name)
  end

  #------------------------------------------------------------------------------
  #
  # Instance Methods
  #
  #------------------------------------------------------------------------------
        

  # This must be overriden otherwise a stack error will occur  
  def get_update
    vehicle_storage_method_type unless vehicle_storage_method_type.nil?
  end

  protected

  # Set resonable defaults for a new condition update event
  def set_defaults
    super
    self.asset_event_type ||= AssetEventType.find_by_class_name(self.name)
  end    
  
end

Fix issue with storage method update event initialization
Fix issue with storage method update event initialization
