Module: SoftDeletable::MacroMethods
- Defined in:
- lib/soft-deletable.rb
Instance Method Summary collapse
Instance Method Details
#acts_as_soft_deletable(opts = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/soft-deletable.rb', line 42 def acts_as_soft_deletable(opts={}) cattr_accessor :aasd_dependents, :aasd_depends_on, :table_name self.aasd_dependents = opts[:dependents] || {} self.aasd_depends_on = opts[:depends_on] || {} self.table_name = opts[:table_name] || self.to_s.tableize self.send(:include, InstanceMethods) # need to add the table name to the query to avoid ambiguous columns default_scope where("#{table_name}.deleted_at IS NULL") scope :deleted, where("#{table_name}.deleted_at IS NOT NULL") end |