Removed acts_as_paranoid. Implemented own version.

This commit is contained in:
Benjamin Meichsner 2013-03-16 17:53:24 +01:00
parent 8bafb3f4b2
commit 07581b7ecf
25 changed files with 93 additions and 57 deletions

View file

@ -1,16 +1,16 @@
# encoding: utf-8
class Article < ActiveRecord::Base
acts_as_paranoid # Avoid deleting the article for consistency of order-results
extend ActiveSupport::Memoizable # Ability to cache method results. Use memoize :expensive_method
# Replace numeric seperator with database format
localize_input_of :price, :tax, :deposit
# Associations
belongs_to :supplier, :with_deleted => true
belongs_to :supplier
belongs_to :article_category
has_many :article_prices, :order => "created_at DESC"
scope :undeleted, -> { where(deleted_at: nil) }
scope :available, :conditions => {:availability => true}
scope :not_in_stock, :conditions => {:type => nil}
@ -136,6 +136,15 @@ class Article < ActiveRecord::Base
end
end
def deleted?
deleted_at.present?
end
def mark_as_deleted
check_article_in_use
update_column :deleted_at, Time.now
end
protected
# Checks if the article is in use before it will deleted