Skip to content

Instantly share code, notes, and snippets.

@buk
Created August 24, 2013 13:13
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 buk/6328074 to your computer and use it in GitHub Desktop.
Save buk/6328074 to your computer and use it in GitHub Desktop.
Mein Frage drehte sich um Zeile 15, aber seitdem ich das *rescue nil* da stehen habe, klappt der Verbindungsaufbau :-)
require 'pg'
require 'active_record'
connection_details = {
adapter: 'postgresql',
database: 'toner',
username: 'sebastian',
encoding: 'utf8',
pool: 5
}
# setup the database connection
ActiveRecord::Base.establish_connection(connection_details.merge({databse: 'postgres', schema_search_path: 'public'}))
# create a new toner database
ActiveRecord::Base.connection.create_database(connection_details.fetch(:database)) rescue nil
# establis a database connection
ActiveRecord::Base.establish_connection(connection_details)
# migrate ALL THE THINGS
ActiveRecord::Migrator.migrate("db/migrate/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment