Sha256: fc2c258b8676fd0f948828f6c62c4ecba8dbb1905082613e8a6c7617c1c5ad4c
Contents?: true
Size: 834 Bytes
Versions: 8
Compression:
Stored size: 834 Bytes
Contents
# # Encapulates a Cost and a Date, used to track costs by # date so sums for date ranges can be generated. # class DatedCost < ActiveRecord::Base include E9Rails::ActiveRecord::Initialization money_columns :cost belongs_to :costable, :polymorphic => true validates :date, :date => true validates :cost, :numericality => { :greater_than => 0 } attr_accessor :temp_id def as_json(options={}) {}.tap do |hash| hash[:id] = self.id hash[:cost] = self.cost hash[:date] = self.date hash[:costable_type] = self.costable_type.try(:underscore) hash[:costable_id] = self.costable_id hash[:errors] = self.errors hash.merge!(options) end end protected def _assign_initialization_defaults self.date ||= Date.today end end
Version data entries
8 entries across 8 versions & 1 rubygems