Connect to a database using ActiveRecord outside of Rails
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql2",
:encoding => "utf8",
:reconnect => true,
:pool => 5,
:username => 'root',
:host => "localhost",
:database => "my_database")
Dir.glob('./app/models/*').each { |r| require r }
Written by Steven Shingler
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#