myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3704] trunk/config/initializers/default_content_


From: noreply
Subject: [myexperiment-hackers] [3704] trunk/config/initializers/default_content_types.rb: Fixed issue with default_content_types preventing migrations on a new db
Date: Wed, 11 Sep 2013 11:13:15 +0000 (UTC)

Revision
3704
Author
fbacall
Date
2013-09-11 11:13:15 +0000 (Wed, 11 Sep 2013)

Log Message

Fixed issue with default_content_types preventing migrations on a new db

Modified Paths

Diff

Modified: trunk/config/initializers/default_content_types.rb (3703 => 3704)


--- trunk/config/initializers/default_content_types.rb	2013-09-11 09:27:32 UTC (rev 3703)
+++ trunk/config/initializers/default_content_types.rb	2013-09-11 11:13:15 UTC (rev 3704)
@@ -5,14 +5,16 @@
 
 # Loads a set default content_types into the database
 
-content_types = YAML::load_file("config/content_types.yml")
+if ActiveRecord::Base.connection.table_exists?('content_types')
+  content_types = YAML::load_file("config/content_types.yml")
 
-Rails.logger.debug('Loading content types...')
-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)
+  Rails.logger.debug('Loading content types...')
+  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
 end

reply via email to

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