Class: Sublease::Tenant

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/sublease/tenant.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.delete(id_or_array) ⇒ Object

Overrides standard ActiveRecord::Relation delete to call destroy instead ensuring all callbacks are fired.



12
13
14
# File 'app/models/sublease/tenant.rb', line 12

def delete(id_or_array)
  destroy(id_or_array)
end

.has_many_subleases(lodger, options = {}) ⇒ Object

Establishes an ActiveRecord Association with a forced destroy dependency. Takes the same options as ActiveRecord::Associations::ClassMethods has_many except it will override the dependent option with a dependent: :destroy in order to ensure the destruction of logders when the tenant is destroyed.



19
20
21
# File 'app/models/sublease/tenant.rb', line 19

def has_many_subleases(lodger, options = {})
  has_many lodger.to_sym, options.delete(:dependent), dependent: :destroy
end

Instance Method Details

#deleteObject

Overrides standard object delete to call destroy instead ensuring all callbacks are fired.



26
27
28
# File 'app/models/sublease/tenant.rb', line 26

def delete
  destroy
end