Skip to content

Instantly share code, notes, and snippets.

@pacojp
Created October 27, 2008 11:44
Show Gist options
  • Save pacojp/20083 to your computer and use it in GitHub Desktop.
Save pacojp/20083 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'activerecord'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "192.168.***.***",
:username => "username",
:password => "password",
:database => "database",
:socket => "/var/lib/mysql/mysql.sock",
:encoding =>"utf8")
ArAuto = Module.new
ActiveRecord::Base.connection.tables.each do |table_name|
eval("ArAuto::#{table_name.singularize.camelize} = Class.new(ActiveRecord::Base)")
end
# example for contents table
p ArAuto::Content.find(:all,:limit=>3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment