myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2359] branches/biocat/vendor/plugins/structured_


From: noreply
Subject: [myexperiment-hackers] [2359] branches/biocat/vendor/plugins/structured_data/lib/auto_migrate.rb: improved detection of existing models in structured data plugin
Date: Wed, 31 Mar 2010 04:58:54 -0400 (EDT)

Revision
2359
Author
dgc
Date
2010-03-31 04:58:53 -0400 (Wed, 31 Mar 2010)

Log Message

improved detection of existing models in structured data plugin

Modified Paths

Diff

Modified: branches/biocat/vendor/plugins/structured_data/lib/auto_migrate.rb (2358 => 2359)


--- branches/biocat/vendor/plugins/structured_data/lib/auto_migrate.rb	2010-03-30 22:02:23 UTC (rev 2358)
+++ branches/biocat/vendor/plugins/structured_data/lib/auto_migrate.rb	2010-03-31 08:58:53 UTC (rev 2359)
@@ -97,7 +97,7 @@
 
     # Now that the schema has changed, update all the models
 
-    reload_models(new_tables.keys)
+    load_models(new_tables.keys)
   end
 
   def self.destroy_auto_tables
@@ -151,28 +151,22 @@
     [tables, assocs]
   end
 
-  def self.reload_models(tables)
+  def self.load_models(tables)
     tables.each do |table|
 
-      file_name  = "app/models/#{table.singularize}.rb"
       class_name = table.singularize.camelize
 
-      if File.exists?(file_name)
+      begin
+        Object.const_get(class_name)
+      rescue NameError
 
-        # force reload the model
-        Kernel::load(file_name)
+        # model object not defined.  create it
 
-      else
-
-        # Create a class for it
         c = Class.new(ActiveRecord::Base)
         c.class_eval("acts_as_structured_data(:class_name => '#{class_name}')")
 
         Object.const_set(class_name.to_sym, c)
       end
-
-      # reload the model schema from the database
-      eval(class_name).reset_column_information
     end
   end
 end

reply via email to

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