Last active
August 29, 2015 14:04
-
-
Save apelade/6fb708c1d34c849d12ea to your computer and use it in GitHub Desktop.
Generic database.rb for Padrino to connect with postgres on travis.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# You can use other adapters like: | |
# | |
# ActiveRecord::Base.configurations[:development] = { | |
# :adapter => 'mysql2', | |
# :encoding => 'utf8', | |
# :reconnect => true, | |
# :database => 'your_database', | |
# :pool => 5, | |
# :username => 'root', | |
# :password => '', | |
# :host => 'localhost', | |
# :socket => '/tmp/mysql.sock' | |
# } | |
# | |
ActiveRecord::Base.configurations[:test] = { | |
:adapter => 'postgresql', | |
:encoding => 'utf8', | |
:database => 'padrino_sample_blog_test', | |
:pool => 5, | |
:username => 'postgres', | |
:password => '' | |
} | |
ActiveRecord::Base.configurations[:production] = { | |
:adapter => 'postgresql', | |
:encoding => 'utf8', | |
:database => 'padrino_sample_blog_production', | |
:pool => 5, | |
:username => 'postgres', | |
:password => '' | |
} | |
# Setup our logger | |
ActiveRecord::Base.logger = logger | |
if ActiveRecord::VERSION::MAJOR.to_i < 4 | |
# Raise exception on mass assignment protection for Active Record models. | |
ActiveRecord::Base.mass_assignment_sanitizer = :strict | |
# Log the query plan for queries taking more than this (works | |
# with SQLite, MySQL, and PostgreSQL). | |
ActiveRecord::Base.auto_explain_threshold_in_seconds = 0.5 | |
end | |
# Doesn't include Active Record class name as root for JSON serialized output. | |
ActiveRecord::Base.include_root_in_json = false | |
# Store the full class name (including module namespace) in STI type column. | |
ActiveRecord::Base.store_full_sti_class = true | |
# Use ISO 8601 format for JSON serialized times and dates. | |
ActiveSupport.use_standard_json_time_format = true | |
# Don't escape HTML entities in JSON, leave that for the #json_escape helper | |
# if you're including raw JSON in an HTML page. | |
ActiveSupport.escape_html_entities_in_json = false | |
# Now we can establish connection with our db. | |
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Padrino.env]) | |
# Timestamps are in the utc by default. | |
ActiveRecord::Base.default_timezone = :utc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment