ruby 独立程序 ,如何进入 生产模式 ?

mobilezht 2011-04-15

写了个提问,一直没有 解决。。。。

http://www.iteye.com/problems/63212

请群里的朋友看看。

有了解 http://www.iteye.com/topic/155123 朋友所说在rails 3 下的实现方式。
mobilezht 2011-04-18
各位,有没有关注过 ActiveRecord::Base.new 的实现呢?
mobilezht 2011-04-19
速度提高N 倍,貌似强大 了,请各位鉴定鉴定

require "cache_columns"


require "cache_columns.rb 如下:
module CacheColumns
  module Persistence
   def self.included(base)
    base.instance_eval do
   alias old_attributes_from_column_definition attributes_from_column_definition
   	def attributes_from_column_definition                                                            
        	ActiveRecord::base.columns[table_name].inject({}) do |attributes, column|                                    
          	attributes[column.name] = column.default unless column.name == self.class.primary_key  
          	attributes                                                                           
        	end                                                                                        
      	end  
      	end
    end  
  end
  module ActiveRecord
    @@columns = {}

    def self.included(base)
      base.instance_eval do
      	#p " base.instance_eval "
        alias old_columns columns
        alias old_reset_column_information reset_column_information
				
        def columns
          if  @@columns[table_name].nil?
            @@columns[table_name] = connection.columns(table_name, "#{name} Columns")
            @@columns[table_name].each {|column| column.primary = column.name == primary_key} 
            #p " get  " +  table_name + "  columns .."
          end
          @@columns[table_name]         
        end

        #  # Resets all the cached information about columns, which will cause them to be reloaded on the next request.
        def reset_column_information
          generated_methods.each { |name| undef_method(name) }
          @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = @inheritance_column = nil
          @@columns.delete(table_name)
        end

        def reset_column_cache #:nodoc:
          @@columns = {}      
          #p " reset_column_cache .."          
        end   
  		
      end
    end

    module ActionController
      def self.included(base)
        base.instance_eval do
          alias old_cleanup_application cleanup_application
          # Cleanup the application by clearing out loaded classes so they can
          # be reloaded on the next request without restarting the server.
          def cleanup_application(force = false)
            if Dependencies.load? || force
              ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
              Dependencies.clear
              #ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
              if defined?(ActiveRecord)
                ActiveRecord::Base.clear_reloadable_connections!
                ActiveRecord::Base.reset_column_cache
              end
            end
          end
        end
      end
    end
  end
end
zeeler 2011-05-10
mobilezht 写道

写了个提问,一直没有 解决。。。。

http://www.iteye.com/problems/63212

请群里的朋友看看。

有了解 http://www.iteye.com/topic/155123 朋友所说在rails 3 下的实现方式。


我是从Java转过来的,ruby上是新手,是否可以在后台运行ruby脚本,做个死循环,自己控制进度,不用crontab,这样可以很容易控制describe执行次数
Global site tag (gtag.js) - Google Analytics