From this repo, you can learn:
- How to connect to TiDB Serverless in ruby on rails.
- How to use branching GitHub integration.
This repo is a rails blog example. it includes:
- Articles CRUD based on MVC
- Migration and seed bases on Active Record Migrations
The repo is based on the blog tutorial.
Make sure you have installed the ruby and rails environment.
- clone the code
git clone [email protected]:tidbcloud/branching-rails-example.git
cd branching-rails-example
- Install the dependencies
bundle install
- Fill in the following environment variable defined in
config/database.yml
. You can find the information in the TiDB Serverless console.
export TIDB_DATABASE=
export TIDB_USER=
export TIDB_HOST=
export TIDB_PASSWORD=
export TIDB_CERT_PATH=
- Migrate and seed
rake db:migrate
rake db:seed
- Run the server
rails server
Assume that you have run the rails project on a TiDB Serverless. Next, you can use the Branching GitHub integration to connect the TiDB Serverless to this repo. Then a database branch will be created for every pull request to test the changes before merging the code to the master branch.
This repo has already connected to a TiDB Serverless. Check this pull request to see how we check the migration changes!