Ruby on Rails + Turso
Set up Turso in your Ruby on Rails project in minutes.
This is currently in technical preview. Join us in Discord to report any issues.
Prerequisites
Before you start, make sure you:
- Install the Turso CLI
- Sign up or login to Turso
- Have a Rails app — learn more
Install the libsql_activerecord Rubygem
Add the following to your Gemfile:
Then run:
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.
Use the libsql adapter
Create and run migrations
Generate a migration:
Run the migration:
Define models
Create a model in app/models/product.rb
:
Use in controllers
In your controllers, you can now use ActiveRecord methods to interact with your Turso database:
Execute raw SQL (if needed)
You can also execute raw SQL queries:
Examples
Was this page helpful?