Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Dave

Adding input:focus functionality to IE using prototype.js

  Event.observe(window, 'load', function() {
    var fields = $$("input");
    for (var i = 0; i < fields.length; i++) {
      fields[i].onfocus = function() {this.className += ' focused';}
      fields[i].onblur = function() {this.className = this.className.replace('focused', '');}
    }
  });


in the css file:

input:focus,   /* works in FF without javascript */
input.focused  /* used by js */
   { background-color: #f7cd72; }

Manually transfering records with ActiveRecord

require 'rubygems'
require 'active_record'

class SourceTable < ActiveRecord::Base
  #set_table_name 'any_name'
  self.establish_connection(
    :adapter  => "mysql",
    :host     => "source_host",
    :username => "user",
    #:password => "mypass",
    :database => "source_database"
  )
end

class TargetTable < ActiveRecord::Base
  #set_table_name 'any_name'
  self.establish_connection(
    :adapter  => "mysql",
    :host     => "target_host",
    :username => "user",
    #:password => "mypass",
    :database => "target_database"
  )
end

records = SourceTable.find :all
records.each do |r|
  # transition logic goes here
  # t = TargetTable.new :field_one => 'xyz'
  # t.save
end