Sha256: 1da65b7192f44abbf27a2b38a87e7c7b32c27148e73aae03664e8b59ab15a2ea

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

module Trade
  module Model::CashLog
    extend ActiveSupport::Concern

    included do
      attribute :title, :string
      attribute :tag_str, :string
      attribute :amount, :decimal, precision: 10, scale: 2

      belongs_to :user
      belongs_to :cash
      belongs_to :source, polymorphic: true, optional: true

      validates :title, presence: true

      after_initialize if: :new_record? do
        if self.user_id
          self.cash = user.cash
        else
          self.user_id = cash.user_id
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_trade-0.0.3 app/models/trade/model/cash_log.rb