Skip to content

Instantly share code, notes, and snippets.

@chucai
Last active January 3, 2016 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chucai/8415930 to your computer and use it in GitHub Desktop.
Save chucai/8415930 to your computer and use it in GitHub Desktop.
Rails: mysql active record
adapter: mysql2
username: username
password: password
database: database_name
#!/usr/bin/env ruby
require 'rubygems'
gem 'activerecord'
require 'mysql2'
require 'active_record'
require 'logger'
require 'yaml'
require 'set'
dbconfig = YAML::load(File.open('database.yml'))
ActiveRecord::Base.establish_connection(dbconfig)
ActiveRecord::Base.pluralize_table_names = false
# ActiveRecord::Base.logger = Logger.new(STDOUT)
result = ActiveRecord::Base.connection.execute("SELECT * FROM schema_version ORDER BY updated_at DESC LIMIT 1")
class AdUnit < ActiveRecord::Base
end
ActiveRecord::Base.transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment