Ruby rake file

task :import_projects => :environment do
  o_projects = T4uproject.find(:all)
  for o_project in o_projects
    unless TimeTree.find_by_original_id(o_project.id)
      new_object = o_project.attributes
      new_object['original_id']  =  new_object['id']
        new_object['task']  = false
      new_object.delete_if {|key,value|(key == 'id') || (key == 'parentKey')}
      new_record=TimeTree.create(new_object)
      o_id = o_project.parent_id
      unless o_id.nil?

        unless TimeTree.find_by_original_id(o_id).nil?

          parent=TimeTree.find_by_original_id(o_id)
          new_record.move_to_child_of parent
        end
      end
    end

  end
end


development:
  adapter: mysql
  encoding: utf8
  database: nestedapp_development
  pool: 5
  username: root
  password:
  socket: /var/run/mysqld/mysqld.sock

nested:
  adapter: mysql
  host: 10.0.1.1
  port: 3306
  encoding: utf8
  database: time4u
  pool: 2
  username: 
  password: 
  socket: /var/run/mysqld/mysqld.sock

你可能感兴趣的:(java,mysql,socket,Ruby)