app/models/trade_codes/unit.rb
# == Schema Information
#
# Table name: trade_codes
#
# id :integer not null, primary key
# code :string(255) not null
# name_en :string(255) not null
# type :string(255) not null
# created_at :datetime not null
# updated_at :datetime not null
# name_es :string(255)
# name_fr :string(255)
#
class Unit < TradeCode
include Deletable
validates :code, :length => { :is => 3 }
has_many :term_trade_codes_pairs, :as => :trade_code
has_many :quotas
has_many :shipments, :class_name => 'Trade::Shipment'
after_commit :invalidate_controller_action_cache
protected
def dependent_objects_map
{
'quotas' => quotas,
'shipments' => shipments
}
end
private
def invalidate_controller_action_cache
Api::V1::UnitsController.invalidate_cache
end
end