Diff
Modified: trunk/app/models/blob.rb (2906 => 2907)
--- trunk/app/models/blob.rb 2012-01-19 09:51:21 UTC (rev 2906)
+++ trunk/app/models/blob.rb 2012-01-19 09:54:33 UTC (rev 2907)
@@ -29,14 +29,10 @@
:boost => "rank",
:include => [ :comments ]) if Conf.solr_enable
- belongs_to :content_blob
+ belongs_to :content_blob, :dependent => :destroy
belongs_to :content_type
belongs_to :license
-
- # :dependent => :destroy is not supported in belongs_to in rails 1.2.6
- after_destroy { |b| b.content_blob.destroy }
-
validates_presence_of :content_blob
validates_presence_of :content_type
Modified: trunk/app/models/preview.rb (2906 => 2907)
--- trunk/app/models/preview.rb 2012-01-19 09:51:21 UTC (rev 2906)
+++ trunk/app/models/preview.rb 2012-01-19 09:54:33 UTC (rev 2907)
@@ -9,9 +9,6 @@
acts_as_structured_data
- # :dependent => :destroy is not supported in belongs_to in rails 1.2.6
- after_destroy { |p| p.content_blob.destroy }
-
def file_name(type)
"#{PREFIX}/#{id}/#{type}"
end
Modified: trunk/app/models/workflow.rb (2906 => 2907)
--- trunk/app/models/workflow.rb 2012-01-19 09:51:21 UTC (rev 2906)
+++ trunk/app/models/workflow.rb 2012-01-19 09:54:33 UTC (rev 2907)
@@ -22,15 +22,9 @@
:order => "created_at DESC",
:dependent => :destroy
- belongs_to :content_blob
+ belongs_to :content_blob, :dependent => :destroy
belongs_to :content_type
belongs_to :license
-
- # need to destroy the workflow versions and their content blobs to avoid orphaned records
- before_destroy { |w| w.versions.each do |wv|
- wv.content_blob.destroy if wv.content_blob
- wv.destroy
- end }
before_validation :check_unique_name
before_validation :apply_extracted_metadata
@@ -61,15 +55,12 @@
format_attribute :body
- belongs_to :content_blob
+ belongs_to :content_blob, :dependent => :destroy
belongs_to :content_type
validates_presence_of :content_blob
validates_presence_of :content_type
- # :dependent => :destroy is not supported in belongs_to in rails 1.2.6
- after_destroy { |wv| wv.content_blob.destroy if wv.content_blob }
-
# Update the parent contribution model buy only if this isn't the current version (because the workflow model will take care of that).
# This is required to keep the contribution's updated_at field accurate.
after_save { |wv| wv.workflow.contribution.save if wv.workflow.contribution && wv.version != wv.workflow.current_version }
Modified: trunk/config/base_schema.xml (2906 => 2907)
--- trunk/config/base_schema.xml 2012-01-19 09:51:21 UTC (rev 2906)
+++ trunk/config/base_schema.xml 2012-01-19 09:54:33 UTC (rev 2907)
@@ -95,8 +95,8 @@
<column type="integer" name="svg_blob_id"/>
<column type="datetime" name="created_at"/>
- <belongs-to target="image_blob" class_name="ContentBlob" foreign_key="image_blob_id"/>
- <belongs-to target="svg_blob" class_name="ContentBlob" foreign_key="svg_blob_id"/>
+ <belongs-to target="image_blob" class_name="ContentBlob" dependent="destroy" foreign_key="image_blob_id"/>
+ <belongs-to target="svg_blob" class_name="ContentBlob" dependent="destroy" foreign_key="svg_blob_id"/>
</table>
Modified: trunk/lib/previews.rb (2906 => 2907)
--- trunk/lib/previews.rb 2012-01-19 09:51:21 UTC (rev 2906)
+++ trunk/lib/previews.rb 2012-01-19 09:54:33 UTC (rev 2907)
@@ -5,7 +5,7 @@
self.class_eval do
- belongs_to :preview
+ belongs_to :preview, :dependent => :destroy
def image
preview.image_blob.data if preview && preview.image_blob
Modified: trunk/vendor/plugins/structured_data/lib/auto_migrate.rb (2906 => 2907)
--- trunk/vendor/plugins/structured_data/lib/auto_migrate.rb 2012-01-19 09:51:21 UTC (rev 2906)
+++ trunk/vendor/plugins/structured_data/lib/auto_migrate.rb 2012-01-19 09:54:33 UTC (rev 2907)
@@ -11,7 +11,7 @@
SCHEMA = "config/base_schema.xml"
SCHEMA_D = "config/schema.d"
COLUMN_ATTRIBUTES = ['name', 'type', 'default', 'limit', 'null']
- BELONGS_TO_ATTRIBUTES = ['polymorphic', 'class_name', 'foreign_key']
+ BELONGS_TO_ATTRIBUTES = ['polymorphic', 'class_name', 'foreign_key', 'dependent']
HAS_MANY_ATTRIBUTES = ['target', 'through', 'foreign_key', 'source', 'dependent', 'conditions', 'class_name', 'as']
def self.schema
Modified: trunk/vendor/plugins/structured_data/lib/structured_data.rb (2906 => 2907)
--- trunk/vendor/plugins/structured_data/lib/structured_data.rb 2012-01-19 09:51:21 UTC (rev 2906)
+++ trunk/vendor/plugins/structured_data/lib/structured_data.rb 2012-01-19 09:54:33 UTC (rev 2907)
@@ -39,6 +39,7 @@
bits.push(":polymorphic => #{association[:polymorphic]}") if association[:polymorphic]
bits.push(":class_name => \"#{association[:class_name]}\"") if association[:class_name]
bits.push(":foreign_key => :#{association[:foreign_key]}") if association[:foreign_key]
+ bits.push(":dependent => :#{association[:dependent]}") if association[:dependent]
line = "belongs_to #{bits.join(', ')}"
self.class_eval(line)