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
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 Add your Turso credentials to your Rails credentials file or environment variables.
.env
.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: