Connect a Rails app to your service
Every Tiger Cloud service is a 100% Postgres database hosted in Tiger Cloud with Tiger Data extensions such as TimescaleDB. You connect to your Tiger Cloud service from a standard Rails app configured for Postgres.
- Create a new Rails app configured for Postgres
Rails creates and bundles your app, then installs the standard Postgres Gems.
Install the TimescaleDB gem
Open
Gemfile, add the following line, then save your changes:In Terminal, run the following command:
Connect your app to your Tiger Cloud service
In
<my_app_home>/config/database.ymlupdate the configuration to read securely connect to your Tiger Cloud service by addingurl: <%= ENV['DATABASE_URL'] %>to the default configuration:Set the environment variable for
DATABASE_URLto the value ofService URLfrom your [connection details][connection-info]Create the database:
- Tiger Cloud: nothing to do. The database is part of your Tiger Cloud service.
- Self-hosted TimescaleDB, create the database for the project:
Verify the connection from your app to your Tiger Cloud service:
The result shows the list of extensions in your Tiger Cloud service
| Name | Version | Schema | Description | | -- | -- | -- | -- | | pg_buffercache | 1.5 | public | examine the shared buffer cache| | pg_stat_statements | 1.11 | public | track planning and execution statistics of all SQL statements executed| | plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language| | postgres_fdw | 1.1 | public | foreign-data wrapper for remote Postgres servers| | timescaledb | 2.18.1 | public | Enables scalable inserts and complex queries for time-series data (Community Edition)| | timescaledb_toolkit | 1.19.0 | public | Library of analytical hyperfunctions, time-series pipelining, and other SQL utilities|