Default scope for BPs ignores deleted records

This commit is contained in:
Rob Harrington
2015-07-01 12:55:48 +08:00
parent 4d58faefd8
commit f0fa696d2f

View File

@@ -2,6 +2,8 @@ class BillablePeriod < ActiveRecord::Base
belongs_to :enterprise
belongs_to :owner, class_name: 'Spree::User', foreign_key: :owner_id
default_scope where(deleted_at: nil)
def bill
# Will make this more sophisicated in the future in that it will use global config variables to calculate
return 0 if trial?
@@ -12,4 +14,8 @@ class BillablePeriod < ActiveRecord::Base
0
end
end
def delete
self.update_column(:deleted_at, Time.now)
end
end