{"id":44103140,"url":"https://github.com/conradwt/cockroach-example-using-ruby","last_synced_at":"2026-02-08T14:37:41.181Z","repository":{"id":38207070,"uuid":"366943874","full_name":"conradwt/cockroach-example-using-ruby","owner":"conradwt","description":"The purpose of this step by step tutorial is to provide a very simple example of configuring and using Cockroach database engine with the Ruby Language.","archived":false,"fork":false,"pushed_at":"2024-05-13T08:47:23.000Z","size":187,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-13T09:56:47.943Z","etag":null,"topics":["cockroachdb","ruby","ruby-on-rails","tutorial"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/conradwt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-13T05:28:58.000Z","updated_at":"2024-05-13T08:47:25.000Z","dependencies_parsed_at":"2023-01-23T04:31:48.195Z","dependency_job_id":null,"html_url":"https://github.com/conradwt/cockroach-example-using-ruby","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/conradwt/cockroach-example-using-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conradwt%2Fcockroach-example-using-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conradwt%2Fcockroach-example-using-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conradwt%2Fcockroach-example-using-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conradwt%2Fcockroach-example-using-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conradwt","download_url":"https://codeload.github.com/conradwt/cockroach-example-using-ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conradwt%2Fcockroach-example-using-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29233476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T14:18:14.570Z","status":"ssl_error","status_checked_at":"2026-02-08T14:18:14.071Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cockroachdb","ruby","ruby-on-rails","tutorial"],"created_at":"2026-02-08T14:37:40.883Z","updated_at":"2026-02-08T14:37:41.175Z","avatar_url":"https://github.com/conradwt.png","language":"Ruby","readme":"# Cockroach Example Using Ruby\n\nThe purpose of this step by step tutorial is to provide a very simple example of configuring and using Cockroach database engine with the Ruby Language.\n\n## Requirements\n\n- CockroachDB 22.2.0 or newer\n\n- Libpq 7.2.0 or newer\n\n- Node 18.12.1 or newer\n\n- Rails 7.0.4.1 or newer\n\n- Ruby 3.1.2 or newer\n\n- Yarn 1.22.19 or newer\n\nNote: This tutorial was created using macOS 12.6.2.\n\n## Communication\n\n- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/cockroachdb). (Tag 'cockroachdb')\n- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/cockroachdb).\n- If you **found a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n## Installation, Setup, and Usage\n\n1.  Open new terminal window\n\n2.  Create node1 of CockroachDB Cluster\n\n    ```zsh\n    cockroach start \\\n    --insecure \\\n    --store=node1 \\\n    --listen-addr=localhost:26257 \\\n    --http-addr=localhost:8080 \\\n    --join=localhost:26257,localhost:26258,localhost:26259 \\\n    --background\n    ```\n\n3.  Create node2 of CockroachDB Cluster\n\n    ```zsh\n    cockroach start \\\n    --insecure \\\n    --store=node2 \\\n    --listen-addr=localhost:26258 \\\n    --http-addr=localhost:8081 \\\n    --join=localhost:26257,localhost:26258,localhost:26259 \\\n    --background\n    ```\n\n4.  Create node3 of CockroachDB Cluster\n\n    ```zsh\n    cockroach start \\\n    --insecure \\\n    --store=node3 \\\n    --listen-addr=localhost:26259 \\\n    --http-addr=localhost:8082 \\\n    --join=localhost:26257,localhost:26258,localhost:26259 \\\n    --background\n    ```\n\n5.  Perform one-time initialization the CockroachDB Cluster\n\n    ```zsh\n    cockroach init --insecure --host=localhost:26257\n    ```\n\n    Note: One should see the following successful message:\n\n    ```zsh\n    Cluster successfully initialized\n    ```\n\n6.  Connect to the built-in SQL Client\n\n    ```zsh\n    cockroach sql --insecure --host=localhost:26257\n    ```\n\n7.  Create the database by entering the following within the console:\n\n    e.g.\n\n    ```zsh\n    root@127.0.0.1:26257/defaultdb\u003e CREATE DATABASE cockroach_example_using_rails_development;\n    ```\n\n8.  Open another terminal window\n\n9.  Generate a new Rails application\n\n    ```zsh\n    rails new cockroach-example-using-ruby -d postgresql --skip-active-storage --skip-javascript -T --no-rc\n    ```\n\n10. Add the ActiveRecord CockroachDB Adapter by doing the following:\n\n    ```zsh\n    bundle remove pg\n    bundle add activerecord-cockroachdb-adapter --version \"~\u003e 7.0.0\"\n    bundle add sassc-rails\n    ```\n\n11. Update the database adapter as follows within `database.yml`:\n\n    replace\n\n    ```yml\n    adapter: postgresql\n    ```\n\n    with\n\n    ```yml\n    adapter: cockroachdb\n    ```\n\n12. Add the following after the `pool: \u003c%= ENV.fetch(\"RAILS_MAX_THREADS\") { 5 } %\u003e` setting within `database.yml`:\n\n    ```yml\n    host: \u003c%= ENV.fetch(\"COCKROACH_HOST\") { 'localhost' } %\u003e\n    port: \u003c%= ENV.fetch(\"COCKROACH_PORT\") { 26257 } %\u003e\n    user: \u003c%= ENV.fetch(\"COCKROACH_USER\") { 'root' } %\u003e\n    password: \u003c%= ENV.fetch(\"COCKROACH_PASSWORD\") { 'admin' } %\u003e\n    requiressl: true\n    ```\n\n13. Generate scaffold of the application\n\n    ```zsh\n    rails g scaffold post title body:text\n    ```\n\n14. Migrate the database.\n\n    ```zsh\n    rails db:migrate\n    ```\n\n15. Add the following as the first route within config/routes.rb file:\n\n    ```ruby\n    root 'posts#index'\n    ```\n\n16. Start the Rails server\n\n    ```zsh\n    rails s\n    ```\n\n17. Play with the application\n\n    ```zsh\n    open http://localhost:3000\n    ```\n\n18. Clean CockroachDB Cluster\n\n    ```zsh\n    cockroach quit --insecure --host=localhost:26257\n    cockroach quit --insecure --host=localhost:26258\n    cockroach quit --insecure --host=localhost:26259\n    rm -rf node1 node2 node3\n    ```\n\n---\n\n## References\n\n- [CockroachDB](https://www.cockroachlabs.com)\n\n- [Hello World Ruby ActiveRecord](https://github.com/cockroachlabs/hello-world-ruby-activerecord)\n\n- [ActiveRecord CockroachDB Adapter](https://github.com/cockroachdb/activerecord-cockroachdb-adapter)\n\n## Support\n\nBug reports and feature requests can be filed for the cassandra-example-using-ruby project here:\n\n- [File Bug Reports and Features](https://github.com/conradwt/cockroach-example-using-ruby/issues)\n\n## Contact\n\nFollow Conrad Taylor on Twitter ([@conradwt](https://twitter.com/conradwt))\n\n## Creator\n\n- [Conrad Taylor](http://github.com/conradwt) ([@conradwt](https://twitter.com/conradwt))\n\n## License\n\nThis repository is released under the [MIT License](./LICENSE.md).\n\n## Copyright\n\n\u0026copy; Copyright 2021 - 2023 Conrad Taylor. All Rights Reserved.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconradwt%2Fcockroach-example-using-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconradwt%2Fcockroach-example-using-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconradwt%2Fcockroach-example-using-ruby/lists"}