myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3589] branches/component-api/config/initializers


From: noreply
Subject: [myexperiment-hackers] [3589] branches/component-api/config/initializers/default_content_types.rb: Wrapped content type creation in a transaction
Date: Mon, 8 Jul 2013 12:38:51 +0000 (UTC)

Revision
3589
Author
fbacall
Date
2013-07-08 12:38:50 +0000 (Mon, 08 Jul 2013)

Log Message

Wrapped content type creation in a transaction

Modified Paths

Diff

Modified: branches/component-api/config/initializers/default_content_types.rb (3588 => 3589)


--- branches/component-api/config/initializers/default_content_types.rb	2013-07-03 08:34:07 UTC (rev 3588)
+++ branches/component-api/config/initializers/default_content_types.rb	2013-07-08 12:38:50 UTC (rev 3589)
@@ -8,9 +8,11 @@
 content_types = YAML::load_file("config/content_types.yml")
 
 Rails.logger.debug('Loading content types...')
-content_types.each do |k,v|
-  unless ContentType.find_by_title_and_mime_type_and_category(v['title'], v['mime_type'], v['category'])
-    Rails.logger.debug("\tCreating #{v['title']}: #{v['mime_type']}")
-    ContentType.create(v)
+ContentType.transaction do
+  content_types.each do |k,v|
+    unless ContentType.find_by_title_and_mime_type_and_category(v['title'], v['mime_type'], v['category'])
+      Rails.logger.debug("\tCreating content type #{v['title']}: #{v['mime_type']}")
+      ContentType.create(v)
+    end
   end
 end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]