Added callback that removes images files when a screenshot gets destroyed
This commit is contained in:
parent
8b9b40fdee
commit
dc17ff1e3e
2 changed files with 30 additions and 2 deletions
|
|
@ -5,7 +5,10 @@ class Package < ActiveRecord::Base
|
|||
# TODO: Make search weighted on users' rating
|
||||
pg_search_scope :general_search, :against => [:name, :description, :long_description]
|
||||
|
||||
has_many :screenshots, :inverse_of=>:package
|
||||
# I am using "destroy_all" here so that when a package gets destroys the
|
||||
# callbacks for all dependent screenshots are executed - thus removing the
|
||||
# screenshot files from disk.
|
||||
has_many :screenshots, :inverse_of=>:package, :dependent => :destroy
|
||||
|
||||
default_scope {
|
||||
order('name ASC')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue