Skip to content

Instantly share code, notes, and snippets.

@shaoshing
Created January 16, 2014 17:26
Show Gist options
  • Save shaoshing/8459351 to your computer and use it in GitHub Desktop.
Save shaoshing/8459351 to your computer and use it in GitHub Desktop.
Using ActiveRecord in jRuby
require 'yaml'
require 'active_record'
require 'models'
database_configs = YAML.load(File.read "database.yml")
ActiveRecord::Base.establish_connection(
:adapter=> database_configs["adapter"],
:host => database_configs["host"],
:database=> database_configs["database"],
:username => database_configs["user"],
:password => database_configs["password"]
)
class Page < ActiveRecord::Base
end
puts Page.first
host: 127.0.0.1
adapter: jdbcmysql
user: root
password:
port:
database: development
source "https://rubygems.org"
gem 'activerecord', '~> 3.2.14'
gem 'activerecord-jdbcmysql-adapter', :platform => :jruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment