Cloud 66 supports stacks based on the Rails framework, a web framework written in Ruby.
Connect to your database
If a database is detected, it will automatically be provisioned as required (including the database itself), and environment variables will be created. You will need to update your code with the environment variables you wish to use, for example
Should you wish to change the database username/password after build, you will have to do this manually, which will involve recreating backup jobs to reflect the new values.
Examples of connecting to your database
The notation in the examples below allow you to seamlessly switch between your local development environment and your Cloud 66 environment without changing your database settings. The logic will determine if the Cloud 66 environment variable exists, and depending on the result, generate a value or use your own value. Alternatively, you can simply hard-code values as you wish.
You can use Yamllint.com to check your YAML syntax before committing.
development: adapter: mysql2 username: <%= ENV['MYSQL_USERNAME'] %> password: <%= ENV['MYSQL_PASSWORD'] %> database: <%= ENV['MYSQL_DATABASE'] %> host: <%= ENV['MYSQL_ADDRESS'] %>
The default encoding used is UTF8 - but you can also specify your own, as long as it conforms with the supported MySQL encodings:
development: adapter: postgresql username: <%= ENV['POSTGRESQL_USERNAME'] %> password: <%= ENV['POSTGRESQL_PASSWORD'] %> database: <%= ENV['POSTGRESQL_DATABASE'] %> host: <%= ENV['POSTGRESQL_ADDRESS'] %>
The default encoding used is UTF8 - but you can also specify your own, as long as it conforms with the supported PostgreSQL encodings:
encoding: latin1 template: template0
development: sessions: default: database: <%= ENV['MONGODB_DATABASE'] %> hosts: ["<%= ENV['MONGODB_ADDRESS']%>:27017"]