Cloud 66

Rails stacks

Cloud 66 makes it easy to deploy and maintain Rails apps

Contents

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 MYSQL_URL.

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.

Note

You can use Yamllint.com to check your YAML syntax before committing.

MySQL YML

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:

encoding: swe7

PostgreSQL YML

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

Mongoid

development:
  sessions:
    default:
      database: <%= ENV['MONGODB_DATABASE'] %>
      hosts: ["<%= ENV['MONGODB_ADDRESS']%>:27017"]

Example application