Skip to main content
This is currently in technical preview. Join us in Discord to report any issues.

Prerequisites

Before you start, make sure you:
1

Install the libsql_activerecord Rubygem

Add the following to your Gemfile:
Then run:
2

Configure database credentials

Get the database URL:
Get the database authentication token:
Assign credentials to the environment variables inside .env.
Add your Turso credentials to your Rails credentials file or environment variables.
3

Use the libsql adapter

4

Create and run migrations

Generate a migration:
Run the migration:
5

Define models

Create a model in app/models/product.rb:
6

Use in controllers

In your controllers, you can now use ActiveRecord methods to interact with your Turso database:
7

Execute raw SQL (if needed)

You can also execute raw SQL queries:

Examples

Ruby on Rails App

See the full source code