myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2890] trunk/Rakefile: added the code to assign c


From: noreply
Subject: [myexperiment-hackers] [2890] trunk/Rakefile: added the code to assign content type categories as a rake task
Date: Wed, 4 Jan 2012 06:50:18 -0500 (EST)

Revision
2890
Author
dgc
Date
2012-01-04 06:50:17 -0500 (Wed, 04 Jan 2012)

Log Message

added the code to assign content type categories as a rake task

Modified Paths

Diff

Modified: trunk/Rakefile (2889 => 2890)


--- trunk/Rakefile	2011-12-21 17:48:32 UTC (rev 2889)
+++ trunk/Rakefile	2012-01-04 11:50:17 UTC (rev 2890)
@@ -156,3 +156,23 @@
   ActiveRecord::Base.record_timestamps = true
 end
 
+desc 'Assign categories to content types'
+task "myexp:types:assign_categories" do
+  require File.dirname(__FILE__) + '/config/environment'
+
+  workflow_content_types = Workflow.find(:all).group_by do |w| w.content_type_id end.keys
+
+  ContentType.find(:all).each do |content_type|
+
+    next if content_type.category
+
+    if workflow_content_types.include?(content_type.id)
+      category = "Workflow"
+    else
+      category = "Blob"
+    end
+
+    content_type.update_attribute("category", category)
+  end
+end
+

reply via email to

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