{"id":10248,"date":"2025-12-22T20:01:49","date_gmt":"2025-12-23T04:01:49","guid":{"rendered":"https:\/\/www.couchbase.com\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/"},"modified":"2025-12-22T20:01:49","modified_gmt":"2025-12-23T04:01:49","slug":"quickstart-ruby-couchbase-orm","status":"publish","type":"tutorials","link":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/","title":{"rendered":"Quickstart in Couchbase with Ruby Couchbase ORM"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In this tutorial, you will learn how to connect to a Couchbase Capella cluster to create, read, update, and delete documents and how to write simple parametrized SQL++ queries.<\/p>\n\n\n\n<h3 id=\"h-prerequisites\" class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To run this prebuilt project, you will need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p><a href=\"https:\/\/www.couchbase.com\/products\/capella\/\">Couchbase Capella<\/a> cluster with <a href=\"https:\/\/docs.couchbase.com\/ruby-sdk\/current\/ref\/travel-app-data-model.html\">travel-sample<\/a> bucket loaded.<\/p>\n<ul>\n<li>To run this tutorial using a self managed Couchbase cluster, please refer to the <a href=\"#running-self-managed-couchbase-cluster\">appendix<\/a>.<\/li>\n<\/ul>\n<\/li>\n\n\n<li>\n<p><a href=\"https:\/\/www.ruby-lang.org\/en\/documentation\/installation\/\">Ruby<\/a> installed on your machine.<\/p>\n<ul>\n<li>Ensure that the Ruby version is <a href=\"https:\/\/docs.couchbase.com\/ruby-sdk\/current\/project-docs\/compatibility.html#ruby-version-compatibility\">compatible<\/a> with the Couchbase SDK.<\/li>\n<\/ul>\n<\/li>\n\n\n<li>\n<p>Loading Travel Sample Bucket\nIf travel-sample is not loaded in your Capella cluster, you can load it by following the instructions for your Capella Cluster:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.couchbase.com\/cloud\/clusters\/data-service\/import-data-documents.html#import-sample-data\">Load travel-sample bucket in Couchbase Capella<\/a><\/li>\n<\/ul>\n<\/li>\n\n<\/ul>\n\n\n\n<h4 id=\"h-couchbase-capella-configuration\" class=\"wp-block-heading\">Couchbase Capella Configuration<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">When running Couchbase using <a href=\"https:\/\/cloud.couchbase.com\/\">Capella<\/a>, the following prerequisites need to be met.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The application requires the travel-sample bucket to be <a href=\"https:\/\/docs.couchbase.com\/cloud\/clusters\/data-service\/import-data-documents.html#import-sample-data\">loaded<\/a> in the cluster from the Capella UI.<\/li>\n\n\n<li>Create the <a href=\"https:\/\/docs.couchbase.com\/cloud\/clusters\/manage-database-users.html\">database credentials<\/a> to access the travel-sample bucket (Read and Write) used in the application.<\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/cloud\/clusters\/allow-ip-address.html\">Allow access<\/a> to the Cluster from the IP on which the application is running.<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-app-setup\" class=\"wp-block-heading\">App Setup<\/h3>\n\n\n\n<h4 id=\"h-cloning-repo\" class=\"wp-block-heading\">Cloning Repo<\/h4>\n\n\n\n<pre class=\"wp-block-code language-shell\"><code>git clone https:\/\/github.com\/couchbase-examples\/ruby-couchbase-orm-quickstart.git\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-install-dependencies\" class=\"wp-block-heading\">Install Dependencies<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The dependencies for the application are specified in the <code>Gemfile<\/code> file in the source folder. Dependencies can be installed through <code>bundler<\/code> the default package manager for Ruby.<\/p>\n\n\n\n<pre class=\"wp-block-code language-shell\"><code>cd ruby-couchbase-orm-quickstart\ngem install bundler\nbundle install\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Refer to the <a href=\"https:\/\/github.com\/couchbase\/couchbase-ruby-client#installation\">instructions in the SDK<\/a> for more info.<\/p>\n<\/blockquote>\n\n\n\n<h4 id=\"h-setup-database-configuration\" class=\"wp-block-heading\">Setup Database Configuration<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">To use Couchbase ORM in your Ruby application, you need to configure the connection settings for your Couchbase Server instance. Couchbase ORM provides a simple way to configure the connection.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\n<p><strong>Rails Applications<\/strong>:<\/p>\n<p>If you&#8217;re using Couchbase ORM in a Rails application, create a new configuration file named <code>couchbase.yml<\/code> in the <code>config<\/code> directory of your Rails project. Add the following content to the file:<\/p>\n<pre><code class=\"language-yaml\">development:\n  connection_string: couchbase:\/\/localhost\n  bucket: my_app_development\n  username: my_username\n  password: my_password\n\ntest:\n  connection_string: couchbase:\/\/localhost\n  bucket: my_app_test\n  username: my_username\n  password: my_password\n\nproduction:\n  connection_string: couchbase:\/\/localhost\n  bucket: my_app_production\n  username: my_username\n  password: my_password\n<\/code><\/pre>\n<p>Replace the values for <code>connection_string<\/code>, <code>bucket<\/code>, <code>username<\/code>, and <code>password<\/code> with your actual Couchbase Server connection details.<\/p>\n<p>CouchbaseOrm will automatically load the configuration based on the current Rails environment.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Non-Rails Applications<\/strong>:<\/p>\n<p>For non-Rails applications, you can configure the connection settings programmatically. Add the following code to your application&#8217;s initialization file or before you start using Couchbase ORM:<\/p>\n<pre><code class=\"language-ruby\">CouchbaseOrm.configure do |config|\n  config.connection_string = 'couchbase:\/\/localhost'\n  config.bucket = 'my_app'\n  config.username = 'my_username'\n  config.password = 'my_password'\nend\n<\/code><\/pre>\n<p>Replace the values for <code>connection_string<\/code>, <code>bucket<\/code>, <code>username<\/code>, and <code>password<\/code> with your actual Couchbase Server connection details.<\/p>\n<\/li>\n\n<\/ol>\n\n\n\n<h3 id=\"h-running-the-application\" class=\"wp-block-heading\">Running the Application<\/h3>\n\n\n\n<h4 id=\"h-directly-on-local-machine\" class=\"wp-block-heading\">Directly on Local Machine<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">At this point, we have installed the dependencies, loaded the travel-sample data and configured the application with the credentials. The application is now ready and you can run it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The application will run on port 3000 of your local machine (<a href=\"http:\/\/localhost:3000\">http:\/\/localhost:3000<\/a>). You will find the Swagger documentation of the API which you can use to try the API endpoints.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Swagger Page will be available at <a href=\"http:\/\/localhost:3000\/api-docs\">http:\/\/localhost:3000\/api-docs<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-shell\"><code>rails s\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-using-docker\" class=\"wp-block-heading\">Using Docker<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you prefer to run this quick start using Docker, we have provided the Dockerfile which you can use to build the image and run the API as a container.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Build the Docker image<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-sh\"><code>docker build -t ruby-couchbase-orm-quickstart .\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run the Docker image<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-sh\"><code>docker run --env-file dev.env -p 3000:3000 ruby-couchbase-orm-quickstart\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Note: This app reads Couchbase connection settings from <code>config\/couchbase.yml<\/code>. Ensure this file is included in the image (COPY) or mount it into the container at runtime.<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Once the app is up and running, open <a href=\"http:\/\/localhost:3000\/api-docs\">http:\/\/localhost:3000\/api-docs<\/a> to test the APIs.<\/p>\n\n\n\n<h4 id=\"h-verifying-the-application\" class=\"wp-block-heading\">Verifying the Application<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Once the application starts, you can see the details of the application on the logs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/app_startup.png\" alt=\"Application Startup\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The application will run on port 3000 of your local machine (<a href=\"http:\/\/localhost:3000\">http:\/\/localhost:3000<\/a>). You will find the interactive Swagger documentation of the API if you go to the URL in your browser. Swagger documentation is used in this demo to showcase the different API end points and how they can be invoked. More details on the Swagger documentation can be found in the <a href=\"#swagger-documentation\">appendix<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\"swagger_documentation.png\" alt=\"Swagger Documentation\"><\/p>\n\n\n\n<h3 id=\"h-health-check-endpoint\" class=\"wp-block-heading\">Health Check Endpoint<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The application provides a health check endpoint for monitoring the service and its dependencies:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Endpoint:<\/strong> <code>GET \/api\/v1\/health<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Response (200 OK) &#8211; All services healthy:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n  &quot;status&quot;: &quot;healthy&quot;,\n  &quot;timestamp&quot;: &quot;2025-12-02T10:00:00Z&quot;,\n  &quot;services&quot;: {\n    &quot;couchbase&quot;: {\n      &quot;status&quot;: &quot;up&quot;,\n      &quot;message&quot;: &quot;Connected to Couchbase bucket: travel-sample&quot;\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Response (503 Service Unavailable) &#8211; Service unhealthy:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n  &quot;status&quot;: &quot;unhealthy&quot;,\n  &quot;timestamp&quot;: &quot;2025-12-02T10:00:00Z&quot;,\n  &quot;services&quot;: {\n    &quot;couchbase&quot;: {\n      &quot;status&quot;: &quot;down&quot;,\n      &quot;message&quot;: &quot;Connection error details&quot;\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Usage:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Monitor application health in production environments<\/li>\n\n\n<li>Use for Kubernetes\/Docker container readiness and liveness probes<\/li>\n\n\n<li>Verify Couchbase connectivity before running tests<\/li>\n\n\n<li>Integrate with monitoring and alerting systems<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-data-model\" class=\"wp-block-heading\">Data Model<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For this tutorial, we use three collections, <code>airport<\/code>, <code>airline<\/code> and <code>route<\/code> that contain sample airports, airlines and airline routes respectively. The route collection connects the airports and airlines as seen in the figure below. We use these connections in the quickstart to generate airports that are directly connected and airlines connecting to a destination airport. Note that these are just examples to highlight how you can use SQL++ queries to join the collections.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/travel_sample_data_model.png\" alt=\"Travel Sample Data Model\"><\/p>\n\n\n\n<h3 id=\"h-let-us-review-the-code\" class=\"wp-block-heading\">Let Us Review the Code<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To begin this tutorial, clone the repo and open it up in the IDE of your choice. Now you can learn about how to create, read, update and delete documents in Couchbase Server.<\/p>\n\n\n\n<h4 id=\"h-code-layout\" class=\"wp-block-heading\">Code Layout<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>.\n\u251c\u2500\u2500 app\n\u2502   \u251c\u2500\u2500 controllers\n\u2502   \u2502   \u251c\u2500\u2500 api\n\u2502   \u2502   \u2502   \u2514\u2500\u2500 v1\n\u2502   \u2502   \u2502       \u251c\u2500\u2500 airlines_controller.rb\n\u2502   \u2502   \u2502       \u251c\u2500\u2500 airports_controller.rb\n\u2502   \u2502   \u2502       \u251c\u2500\u2500 health_controller.rb\n\u2502   \u2502   \u2502       \u2514\u2500\u2500 routes_controller.rb\n\u2502   \u2502   \u251c\u2500\u2500 application_controller.rb\n\u2502   \u2502   \u2514\u2500\u2500 concerns\n\u2502   \u251c\u2500\u2500 models\n\u2502   \u2502   \u251c\u2500\u2500 airline.rb\n\u2502   \u2502   \u251c\u2500\u2500 airport.rb\n\u2502   \u2502   \u251c\u2500\u2500 application_record.rb\n\u2502   \u2502   \u251c\u2500\u2500 concerns\n\u2502   \u2502   \u2514\u2500\u2500 route.rb\n\u2502   \u2514\u2500\u2500 views\n\u2502       \u2514\u2500\u2500 layouts\n\u2502           \u251c\u2500\u2500 application.html.erb\n\u2502           \u251c\u2500\u2500 mailer.html.erb\n\u2502           \u2514\u2500\u2500 mailer.text.erb\n\u251c\u2500\u2500 config\n\u2502   \u251c\u2500\u2500 importmap.rb\n\u2502   \u251c\u2500\u2500 initializers\n\u2502   \u2502   \u251c\u2500\u2500 couchbase.rb\n\u2502   \u2502   \u251c\u2500\u2500 rswag_api.rb\n\u2502   \u2502   \u2514\u2500\u2500 rswag_ui.rb\n\u2502   \u251c\u2500\u2500 routes.rb\n\u251c\u2500\u2500 config.ru\n\u251c\u2500\u2500 db\n\u2502   \u2514\u2500\u2500 seeds.rb\n\u251c\u2500\u2500 dev.env\n\u251c\u2500\u2500 dev.env.example\n\u251c\u2500\u2500 Dockerfile\n\u251c\u2500\u2500 Gemfile\n\u251c\u2500\u2500 Gemfile.lock\n\u251c\u2500\u2500 spec\n\u2502   \u251c\u2500\u2500 rails_helper.rb\n\u2502   \u251c\u2500\u2500 requests\n\u2502   \u2502   \u251c\u2500\u2500 api\n\u2502   \u2502   \u2502   \u2514\u2500\u2500 v1\n\u2502   \u2502   \u2502       \u251c\u2500\u2500 airlines_spec.rb\n\u2502   \u2502   \u2502       \u251c\u2500\u2500 airports_spec.rb\n\u2502   \u2502   \u2502       \u2514\u2500\u2500 routes_spec.rb\n\u2502   \u2502   \u2514\u2500\u2500 swagger\n\u2502   \u2502       \u251c\u2500\u2500 airlines_spec.rb\n\u2502   \u2502       \u251c\u2500\u2500 airports_spec.rb\n\u2502   \u2502       \u2514\u2500\u2500 routes_spec.rb\n\u2502   \u251c\u2500\u2500 spec_helper.rb\n\u2502   \u2514\u2500\u2500 swagger_helper.rb\n\u251c\u2500\u2500 swagger\n\u2502   \u2514\u2500\u2500 v1\n\u2502       \u2514\u2500\u2500 swagger.yaml\n\u251c\u2500\u2500 test\n\u2502   \u251c\u2500\u2500 channels\n\u2502   \u2502   \u2514\u2500\u2500 application_cable\n\u2502   \u2502       \u2514\u2500\u2500 connection_test.rb\n\u2502   \u251c\u2500\u2500 controllers\n\u2502   \u251c\u2500\u2500 models\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We have separated out the API code into separate files by the entity (collection) in the <code>api<\/code> folder. The application uses two types of tests:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Integration tests<\/strong> in <code>spec\/requests\/api\/v1\/<\/code> verify actual API functionality<\/li>\n\n\n<li><strong>Swagger documentation specs<\/strong> in <code>spec\/requests\/swagger\/<\/code> generate OpenAPI documentation<\/li>\n\n\n<li>The generated <code>swagger.yaml<\/code> file appears in <code>swagger\/v1\/<\/code><\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In <code>routes.rb<\/code>, we define the routes for the application including the API routes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We have the Couchbase SDK operations defined in the <code>CouchbaseClient<\/code> class inside the <code>config\/initializers\/couchbase.rb<\/code> file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We recommend creating a single Couchbase connection when your application starts up and reusing this connection throughout your application. This approach improves performance by avoiding the overhead of creating new connections for each request. If you know which buckets, scopes, and collections your application will use, obtain these references at startup and share them throughout your application as well.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this application, we have created the connection object in <code>config\/initializers\/couchbase.rb<\/code> and use it in all of our APIs. We have also stored references to the <code>travel-sample<\/code> bucket and the <code>inventory<\/code> scope in global constants for easy access.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>require &#039;couchbase&#039;\n\n# Get environment variables\nDB_USERNAME = ENV[&#039;DB_USERNAME&#039;]\nDB_PASSWORD = ENV[&#039;DB_PASSWORD&#039;]\nDB_CONN_STR = ENV[&#039;DB_CONN_STR&#039;]\nDB_BUCKET_NAME = &#039;travel-sample&#039; # Hardcoded bucket name\n\n# Check if running in CI environment\nif ENV[&#039;CI&#039;]\n  # Use environment variables from GitHub Secrets\n  options = Couchbase::Cluster::ClusterOptions.new\n  options.authenticate(DB_USERNAME, DB_PASSWORD)\n  COUCHBASE_CLUSTER = Couchbase::Cluster.connect(DB_CONN_STR, options)\nelse\n  # Load environment variables from dev.env file\n  require &#039;dotenv&#039;\n  Dotenv.load(&#039;dev.env&#039;)\n\n  # Define default values\n  DEFAULT_DB_USERNAME = &#039;Administrator&#039;\n  DEFAULT_DB_PASSWORD = &#039;password&#039;\n  DEFAULT_DB_CONN_STR = &#039;couchbase:\/\/localhost&#039;\n\n  # Get environment variables with fallback to default values\n  DB_USERNAME = ENV.fetch(&#039;DB_USERNAME&#039;, DEFAULT_DB_USERNAME)\n  DB_PASSWORD = ENV.fetch(&#039;DB_PASSWORD&#039;, DEFAULT_DB_PASSWORD)\n  DB_CONN_STR = ENV.fetch(&#039;DB_CONN_STR&#039;, DEFAULT_DB_CONN_STR)\n\n  # Connect to the Couchbase cluster\n  options = Couchbase::Cluster::ClusterOptions.new\n  options.authenticate(DB_USERNAME, DB_PASSWORD)\n  COUCHBASE_CLUSTER = Couchbase::Cluster.connect(DB_CONN_STR, options)\nend\n\n# Open the bucket\nbucket = COUCHBASE_CLUSTER.bucket(DB_BUCKET_NAME)\n\n# Open the default collection\ndefault_collection = bucket.default_collection\n\n# Create scope and collections if they don&#039;t exist\nbegin\n  scope = bucket.scope(&#039;inventory&#039;)\nrescue Couchbase::Error::ScopeNotFoundError\n  bucket.create_scope(&#039;inventory&#039;)\n  scope = bucket.scope(&#039;inventory&#039;)\nend\n\n%w[airline airport route].each do |collection_name|\n  scope.collection(collection_name)\nrescue Couchbase::Error::CollectionNotFoundError\n  scope.create_collection(collection_name)\nend\n\nAIRLINE_COLLECTION = scope.collection(&#039;airline&#039;)\nAIRPORT_COLLECTION = scope.collection(&#039;airport&#039;)\nROUTE_COLLECTION = scope.collection(&#039;route&#039;)\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the above code, we first get the environment variables for the connection string, username, and password. We then create a connection object using the <code>Couchbase::Cluster.connect<\/code> method. We authenticate the connection using the username and password. We then open the bucket and the default collection. We create a scope and collections if they don&#8217;t exist. We store the reference to the collections in the connection object.<\/p>\n\n\n\n<h4 id=\"h-airline-entity\" class=\"wp-block-heading\">Airline Entity<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">For this tutorial, we will focus on the airline entity. The other entities are similar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We will be setting up a REST API to manage airline documents.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#post-airline\">POST Airline<\/a> \u2013 Create a new airline<\/li>\n\n\n<li><a href=\"#get-airline\">GET Airline<\/a> \u2013 Read specified airline<\/li>\n\n\n<li><a href=\"#put-airline\">PUT Airline<\/a> \u2013 Update specified airline<\/li>\n\n\n<li><a href=\"#delete-airline\">DELETE Airline<\/a> \u2013 Delete airline<\/li>\n\n\n<li><a href=\"#list-airline\">Airline List<\/a> \u2013 Get all airlines. Optionally filter the list by country<\/li>\n\n\n<li><a href=\"#direct-connections\">Direct Connections<\/a> &#8211; Get a list of airlines directly connected to the specified airport<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For CRUD operations, we will use <a href=\"https:\/\/docs.couchbase.com\/ruby-sdk\/current\/howtos\/kv-operations.html\">Key-Value operations<\/a> using the SDK. Every document will need an ID (similar to a primary key in other databases) to save it to the database. This ID is passed in the URL. For other end points, we will use <a href=\"https:\/\/docs.couchbase.com\/ruby-sdk\/current\/howtos\/n1ql-queries-with-sdk.html\">SQL++<\/a> to query for documents.<\/p>\n\n\n\n<h4 id=\"h-airline-document-structure\" class=\"wp-block-heading\">Airline Document Structure<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Our airline document will have an airline name, IATA code, ICAO code, callsign, and country. For this demo, each airline&#8217;s information is stored as a separate document in the <code>airline<\/code> collection in the <code>travel-sample<\/code> bucket.<\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n  &quot;name&quot;: &quot;40-Mile Air&quot;,\n  &quot;iata&quot;: &quot;Q5&quot;,\n  &quot;icao&quot;: &quot;MLA&quot;,\n  &quot;callsign&quot;: &quot;MILE-AIR&quot;,\n  &quot;country&quot;: &quot;United States&quot;\n}\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-post-airline\" class=\"wp-block-heading\">POST Airline<\/h4>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code># frozen_string_literal: true\n\nmodule Api\n  module V1\n    class AirlinesController &lt; ApplicationController\n      skip_before_action :verify_authenticity_token, only: %i[create update destroy]\n      before_action :set_airline, only: %i[show update destroy]\n\n      ...\n      # POST \/api\/v1\/airlines\/{id}\n      def create\n        @airline = Airline.create(params[:id], airline_params)\n        if @airline\n          render json: @airline, status: :created\n        else\n          render json: { message: &#039;Airline already exists&#039; }, status: :conflict\n        end\n      rescue ArgumentError =&gt; e\n        render json: { error: &#039;Invalid request&#039;, message: e.message }, status: :bad_request\n      rescue Couchbase::Error::DocumentExists =&gt; e\n        render json: { error: &quot;Airline with ID #{params[:id]} already exists&quot;, message: e.message }, status: :conflict\n      rescue StandardError =&gt; e\n        render json: { error: &#039;Internal server error&#039;, message: e.message }, status: :internal_server_error\n      end\n    end\n    ...\n\n  end\nend\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the above code, we first create an instance of the <code>Airline<\/code> class using the <code>create<\/code> method. We pass the ID and the airline data to the <code>create<\/code> method. If the airline is created successfully, we return the airline document with a status of 201. If the airline already exists, we return a conflict status of 409. If there are any missing fields in the request, we return a bad request status of 400. If there is any other error, we return an internal server error status of 500.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code># frozen_string_literal: true\n\n# Airline model\nclass Airline\n  attr_accessor :name, :iata, :icao, :callsign, :country\n\n  def initialize(attributes)\n    @name = attributes[&#039;name&#039;]\n    @iata = attributes[&#039;iata&#039;]\n    @icao = attributes[&#039;icao&#039;]\n    @callsign = attributes[&#039;callsign&#039;]\n    @country = attributes[&#039;country&#039;]\n  end\n  ...\n\n  def self.create(id, attributes)\n    required_fields = %w[name iata icao callsign country]\n    missing_fields = required_fields - attributes.keys\n    extra_fields = attributes.keys - required_fields\n\n    raise ArgumentError, &quot;Missing fields: #{missing_fields.join(&#039;, &#039;)}&quot; if missing_fields.any?\n\n    raise ArgumentError, &quot;Extra fields: #{extra_fields.join(&#039;, &#039;)}&quot; if extra_fields.any?\n\n    formatted_attributes = {\n      &#039;name&#039; =&gt; attributes[&#039;name&#039;],\n      &#039;iata&#039; =&gt; attributes[&#039;iata&#039;],\n      &#039;icao&#039; =&gt; attributes[&#039;icao&#039;],\n      &#039;callsign&#039; =&gt; attributes[&#039;callsign&#039;],\n      &#039;country&#039; =&gt; attributes[&#039;country&#039;]\n    }\n    AIRLINE_COLLECTION.insert(id, formatted_attributes)\n    new(formatted_attributes)\n  end\n\n  ...\nend\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the above code, we first check if all the required fields are present in the request. If any fields are missing, we raise an ArgumentError with the missing fields. If there are any extra fields in the request, we raise an ArgumentError with the extra fields. We then format the attributes and insert the document into the database using the <code>insert<\/code> method. We then create a new instance of the <code>Airline<\/code> class with the formatted attributes and return it.<\/p>\n\n\n\n<h4 id=\"h-get-airline\" class=\"wp-block-heading\">GET Airline<\/h4>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>  # GET \/api\/v1\/airlines\/{id}\n  def show\n    if @airline\n      render json: @airline, status: :ok\n    else\n      render json: { error: &quot;Airline with ID #{params[:id]} not found&quot; }, status: :not_found\n    end\n  rescue Couchbase::Error::DocumentNotFound =&gt; e\n    render json: { error: &quot;Airline with ID #{params[:id]} not found&quot;, message: e.message }, status: :not_found\n  rescue StandardError =&gt; e\n    render json: { error: &#039;Internal server error&#039;, message: e.message }, status: :internal_server_error\n  end\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the above code, we retrieve the airline document using the <code>show<\/code> method in the controller. The <code>@airline<\/code> instance variable is set by the <code>set_airline<\/code> before_action callback. If the airline is found, we return the airline document with a status of 200. If the airline is not found, we return a not found status of 404. If there is any other error, we return an internal server error status of 500.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>  def self.find(id)\n    result = AIRLINE_COLLECTION.get(id)\n    new(result.content) if result.success?\n  rescue Couchbase::Error::DocumentNotFound\n    nil\n  end\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the <code>find<\/code> method, we use the <code>get<\/code> method to fetch the document from the database using the key. If the document is found, we create a new instance of the <code>Airline<\/code> class with the document content and return it. If the document is not found, we return <code>nil<\/code>.<\/p>\n\n\n\n<h4 id=\"h-put-airline\" class=\"wp-block-heading\">PUT Airline<\/h4>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>    # PUT \/api\/v1\/airlines\/{id}\n    def update\n      @airline = Airline.new(airline_params).update(params[:id], airline_params)\n      render json: @airline, status: :ok\n    rescue ArgumentError =&gt; e\n      render json: { error: &#039;Invalid request&#039;, message: e.message }, status: :bad_request\n    rescue StandardError =&gt; e\n      render json: { error: &#039;Internal server error&#039;, message: e.message }, status: :internal_server_error\n    end\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the above code, we first create an instance of the <code>Airline<\/code> class using the <code>update<\/code> method. We pass the ID and the airline data to the <code>update<\/code> method. If the airline is updated successfully, we return the airline document with a status of 200. If there are any missing fields in the request, we return a bad request status of 400. If there is any other error, we return an internal server error status of 500.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>  def update(id, attributes)\n    required_fields = %w[name iata icao callsign country]\n    missing_fields = required_fields - attributes.keys\n    extra_fields = attributes.keys - required_fields\n\n    raise ArgumentError, &quot;Missing fields: #{missing_fields.join(&#039;, &#039;)}&quot; if missing_fields.any?\n\n    raise ArgumentError, &quot;Extra fields: #{extra_fields.join(&#039;, &#039;)}&quot; if extra_fields.any?\n\n    formatted_attributes = {\n      &#039;name&#039; =&gt; attributes[&#039;name&#039;],\n      &#039;iata&#039; =&gt; attributes[&#039;iata&#039;],\n      &#039;icao&#039; =&gt; attributes[&#039;icao&#039;],\n      &#039;callsign&#039; =&gt; attributes[&#039;callsign&#039;],\n      &#039;country&#039; =&gt; attributes[&#039;country&#039;]\n    }\n    AIRLINE_COLLECTION.upsert(id, formatted_attributes)\n    self.class.new(formatted_attributes)\n  end\n\n  def destroy(id)\n    AIRLINE_COLLECTION.remove(id)\n  end\nend\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the <code>update<\/code> method, we first check if all the required fields are present in the request. If any fields are missing, we raise an ArgumentError with the missing fields. If there are any extra fields in the request, we raise an ArgumentError with the extra fields. We then format the attributes and update the document in the database using the <code>upsert<\/code> method. We then create a new instance of the <code>Airline<\/code> class with the formatted attributes and return it.<\/p>\n\n\n\n<h4 id=\"h-delete-airline\" class=\"wp-block-heading\">DELETE Airline<\/h4>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>    # DELETE \/api\/v1\/airlines\/{id}\n      def destroy\n        if @airline\n          if @airline.destroy(params[:id])\n            render json: { message: &#039;Airline deleted successfully&#039; }, status: :accepted\n          else\n            render json: { message: &#039;Failed to delete airline&#039; }, status: :bad_request\n          end\n        else\n          render json: { error: &quot;Airline with ID #{params[:id]} not found&quot; }, status: :not_found\n        end\n      rescue Couchbase::Error::DocumentNotFound =&gt; e\n        render json: { error: &quot;Airline with ID #{params[:id]} not found&quot;, message: e.message }, status: :not_found\n      rescue StandardError =&gt; e\n        render json: { error: &#039;Internal server error&#039;, message: e.message }, status: :internal_server_error\n      end\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the above code, we first check if the airline document exists. If the document exists, we call the <code>destroy<\/code> method on the <code>Airline<\/code> class. If the document is deleted successfully, we return a status of 202. If the document is not deleted successfully, we return a bad request status of 400. If the document is not found, we return a not found status of 404. If there is any other error, we return an internal server error status of 500.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>  def destroy(id)\n    AIRLINE_COLLECTION.remove(id)\n  end\nend\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-list-airlines\" class=\"wp-block-heading\">List Airlines<\/h4>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>  # GET \/api\/v1\/airlines\/list\n  def index\n    country = params[:country]\n    limit = params[:limit] || 10\n    offset = params[:offset] || 0\n\n    @airlines = Airline.all(country, limit, offset)\n\n    if @airlines.empty?\n      render json: { message: &#039;No airlines found&#039; }, status: :ok\n    else\n      render json: @airlines, status: :ok\n    end\n  rescue StandardError =&gt; e\n    render json: { error: &#039;Internal server error&#039;, message: e.message }, status: :internal_server_error\n  end\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the above code, we first get the values for the country, limit, and offset from the request parameters. We then call the <code>all<\/code> method in the <code>Airline<\/code> class to fetch the list of airlines. If the list is empty, we return a status of 200 with a message. If the list is not empty, we return a status of 200 with the list of airlines. If there is any other error, we return an internal server error status of 500.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>  def self.all(country = nil, limit = 10, offset = 0)\n    bucket_name = &#039;travel-sample&#039;\n    scope_name = &#039;inventory&#039;\n    collection_name = &#039;airline&#039;\n\n    query = country ? &quot;SELECT * FROM `#{bucket_name}`.`#{scope_name}`.`#{collection_name}` WHERE country = $country LIMIT $limit OFFSET $offset&quot; : &quot;SELECT * FROM `#{bucket_name}`.`#{scope_name}`.`#{collection_name}` LIMIT $limit OFFSET $offset&quot;\n    options = Couchbase::Cluster::QueryOptions.new\n    options.named_parameters(country ? { &#039;country&#039; =&gt; country, &#039;limit&#039; =&gt; limit.to_i,\n                                         &#039;offset&#039; =&gt; offset.to_i } : { &#039;limit&#039; =&gt; limit.to_i, &#039;offset&#039; =&gt; offset.to_i })\n\n    result = COUCHBASE_CLUSTER.query(query, options)\n    result.rows.map { |row| new(row.fetch(&#039;airline&#039;, {})) }.to_a\n  end\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the <code>all<\/code> method, we first define the bucket, scope, and collection names. We then build the SQL++ query based on the country parameter. We then create a <code>QueryOptions<\/code> object and set the named parameters based on the country parameter. We then execute the query using the <code>query<\/code> method and iterate over the results to create a list of <code>Airline<\/code> objects and return it.<\/p>\n\n\n\n<h4 id=\"h-direct-connections\" class=\"wp-block-heading\">Direct Connections<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to the <code>direct_connections<\/code> method in the <code>AirportController<\/code> class in the <code>airports_controller.rb<\/code> file. We only need the airport document ID or our key from the user to retrieve a list of airlines directly connected to the specified airport using a SQL++ query. The result is converted into a JSON object using the <code>to_json<\/code> method.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rb\"><code>def direct_connections\n  destination_airport_code = params[:destinationAirportCode]\n  limit = params[:limit] || 10\n  offset = params[:offset] || 0\n\n  if destination_airport_code.blank?\n    render json: { message: &#039;Destination airport code is required&#039; }, status: :bad_request\n  else\n    @connections = Airport.direct_connections(destination_airport_code, limit, offset)\n    render json: @connections, status: :ok\n  end\nrescue StandardError =&gt; e\n  render json: { error: &#039;Internal server error&#039;, message: e.message }, status: :internal_server_error\nend\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-running-tests\" class=\"wp-block-heading\">Running Tests<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We have defined integration tests using <a href=\"https:\/\/rspec.info\/\">RSpec<\/a> for all the API end points. The integration tests use the same database configuration as the application. For the tests, we perform the operation using the API and confirm the results by checking the documents in the database. For example, to check the creation of the document by the API, we would call the API to create the document and then read the same document directly from the database and compare them. After the tests, the documents are cleaned up.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To run the integration tests:<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>bundle exec rspec spec\/requests\/api\/v1\/\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To generate the Swagger\/OpenAPI documentation:<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>bundle exec rake rswag:specs:swaggerize\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The integration tests verify actual API functionality, while the swagger specs are documentation-only and generate the OpenAPI specification file.<\/p>\n\n\n\n<h3 id=\"h-appendix\" class=\"wp-block-heading\">Appendix<\/h3>\n\n\n\n<h4 id=\"h-extending-api-by-adding-new-entity\" class=\"wp-block-heading\">Extending API by Adding New Entity<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you would like to add another entity to the APIs, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\n<p><strong>Create the new collection in Couchbase<\/strong>: Create the new entity (collection) in the Couchbase bucket. You can create the collection using the <a href=\"https:\/\/docs.couchbase.com\/sdk-api\/couchbase-ruby-client\/Couchbase\/Collection.html#create_collection-instance_method\">SDK<\/a> or via the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-settings\/manage-collections.html\">Couchbase Server interface<\/a>.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Create the model<\/strong>: Create a new model file in the <code>app\/models\/<\/code> folder (e.g., <code>app\/models\/hotel.rb<\/code>). Define the model class with attributes and methods for CRUD operations similar to the <code>Airline<\/code> model.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Create the controller<\/strong>: Create a new controller file in the <code>app\/controllers\/api\/v1\/<\/code> folder (e.g., <code>app\/controllers\/api\/v1\/hotels_controller.rb<\/code>). Implement the CRUD action methods (index, show, create, update, destroy) similar to <code>airlines_controller.rb<\/code>.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Add routes<\/strong>: Open <code>config\/routes.rb<\/code> and add the new routes for your entity within the <code>namespace :api<\/code> and <code>namespace :v1<\/code> blocks. For example:<\/p>\n<pre><code class=\"language-ruby\">resources :hotels\n<\/code><\/pre>\n<\/li>\n\n\n<li>\n<p><strong>Add integration tests<\/strong>: Create a new test file in the <code>spec\/requests\/api\/v1\/<\/code> folder (e.g., <code>spec\/requests\/api\/v1\/hotels_spec.rb<\/code>) with comprehensive tests for all CRUD operations. These tests should verify actual functionality by performing database operations and asserting results.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Add Swagger documentation<\/strong>: Create a documentation-only spec file in the <code>spec\/requests\/swagger\/<\/code> folder (e.g., <code>spec\/requests\/swagger\/hotels_spec.rb<\/code>). This should focus on API contract definition without database operations:<\/p>\n<ul>\n<li>Use <code>run_test! do |response|<\/code> blocks with comments referencing the integration tests<\/li>\n<li>Use existing travel-sample data IDs for GET operations<\/li>\n<li>Use placeholder IDs for create\/update\/delete operations<\/li>\n<li>Example:\n<pre><code class=\"language-ruby\">response '200', 'hotel found' do\n  let(:id) { 'hotel_123' }\n  run_test! do |response|\n    # Documentation-only - actual testing in spec\/requests\/api\/v1\/hotels_spec.rb\n  end\nend\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n\n\n<li>\n<p><strong>Generate Swagger docs<\/strong>: Run the command <code>bundle exec rake rswag:specs:swaggerize<\/code> to generate the Swagger documentation.<\/p>\n<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Your new entity is now ready to be used in the API.<\/p>\n\n\n\n<h4 id=\"h-running-self-managed-couchbase-cluster\" class=\"wp-block-heading\">Running Self Managed Couchbase Cluster<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you are running this quickstart with a self managed Couchbase cluster, you need to <a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-settings\/install-sample-buckets.html\">load<\/a> the travel-sample data bucket in your cluster and generate the credentials for the bucket.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Follow <a href=\"\/tutorial-couchbase-installation-options\">Couchbase Installation Options<\/a> for installing the latest Couchbase Database Server Instance.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You need to update the connection string and the credentials in the <code>dev.env<\/code> file in the source folder.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Note: Couchbase Server must be installed and running prior to running the Ruby on Rails App<\/p>\n<\/blockquote>\n\n\n\n<h4 id=\"h-swagger-documentation\" class=\"wp-block-heading\">Swagger Documentation<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Swagger documentation provides a clear view of the API including endpoints, HTTP methods, request parameters, and response objects.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click on an individual endpoint to expand it and see detailed information. This includes the endpoint&#8217;s description, possible response status codes, and the request parameters it accepts.<\/p>\n\n\n\n<h5 id=\"h-trying-out-the-api\" class=\"wp-block-heading\">Trying Out the API<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">You can try out an API by clicking on the &#8220;Try it out&#8221; button next to the endpoints.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p>Parameters: If an endpoint requires parameters, Swagger UI provides input boxes for you to fill in. This could include path parameters, query strings, headers, or the body of a POST\/PUT request.<\/p>\n<\/li>\n\n\n<li>\n<p>Execution: Once you&#8217;ve inputted all the necessary parameters, you can click the &#8220;Execute&#8221; button to make a live API call. Swagger UI will send the request to the API and display the response directly in the documentation. This includes the response code, response headers, and response body.<\/p>\n<\/li>\n\n<\/ul>\n\n\n\n<h5 id=\"h-models\" class=\"wp-block-heading\">Models<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Swagger documents the structure of request and response bodies using models. These models define the expected data structure using JSON schema and are extremely helpful in understanding what data to send and expect.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to connect to a Couchbase Capella cluster to create, read, update, and delete documents and how to write simple parametrized SQL++ queries. Prerequisites To run this prebuilt project, you will need: Couchbase Capella Configuration When running Couchbase using Capella, the following prerequisites need to be met. App Setup [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"_acf":"","footnotes":""},"tutorial-languages":[579],"tutorial-tags":[580,546],"tutorial-technologies":[572,548,549],"tutorial-types":[550],"class_list":["post-10248","tutorials","type-tutorials","status-publish","hentry","tutorial-languages-ruby","tutorial-tags-couchbase-orm","tutorial-tags-rest-api","tutorial-technologies-index","tutorial-technologies-kv","tutorial-technologies-query","tutorial-types-quickstart"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.8 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Quickstart in Couchbase with Ruby Couchbase ORM - Couchbase<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Quickstart in Couchbase with Ruby Couchbase ORM\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to connect to a Couchbase Capella cluster to create, read, update, and delete documents and how to write simple parametrized SQL++ queries. Prerequisites To run this prebuilt project, you will need: Couchbase Capella Configuration When running Couchbase using Capella, the following prerequisites need to be met. App Setup [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/\" \/>\n<meta property=\"og:site_name\" content=\"Couchbase\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Couchbase\/\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2548\" \/>\n\t<meta property=\"og:image:height\" content=\"1171\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@couchbase\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"20\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-ruby-couchbase-orm\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-ruby-couchbase-orm\\\/\",\"name\":\"Quickstart in Couchbase with Ruby Couchbase ORM - Couchbase\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#website\"},\"datePublished\":\"2025-12-23T04:01:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-ruby-couchbase-orm\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-ruby-couchbase-orm\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-ruby-couchbase-orm\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Quickstart in Couchbase with Ruby Couchbase ORM\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/\",\"name\":\"Couchbase\",\"description\":\"The Operational Data Platform for AI\u2122\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#organization\"},\"alternateName\":\"Couchbase, Inc.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#organization\",\"name\":\"Couchbase\",\"alternateName\":\"Couchbase, Inc.\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"width\":1129,\"height\":1129,\"caption\":\"Couchbase\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Couchbase\\\/\",\"https:\\\/\\\/x.com\\\/couchbase\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/CouchbaseServer\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/couchbase\\\/\",\"https:\\\/\\\/github.com\\\/couchbase\\\/\",\"https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Couchbase,_Inc.\"],\"description\":\"Couchbase is a database software company headquartered in San Jose, California, providing an operational data platform for AI used by hundreds of global enterprises.\",\"legalName\":\"Couchbase, Inc.\",\"foundingDate\":\"2011-01-01\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Quickstart in Couchbase with Ruby Couchbase ORM - Couchbase","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/","og_locale":"de_DE","og_type":"article","og_title":"Quickstart in Couchbase with Ruby Couchbase ORM","og_description":"In this tutorial, you will learn how to connect to a Couchbase Capella cluster to create, read, update, and delete documents and how to write simple parametrized SQL++ queries. Prerequisites To run this prebuilt project, you will need: Couchbase Capella Configuration When running Couchbase using Capella, the following prerequisites need to be met. App Setup [&hellip;]","og_url":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/","og_site_name":"Couchbase","article_publisher":"https:\/\/www.facebook.com\/Couchbase\/","og_image":[{"width":2548,"height":1171,"url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@couchbase","twitter_misc":{"Est. reading time":"20\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/","url":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/","name":"Quickstart in Couchbase with Ruby Couchbase ORM - Couchbase","isPartOf":{"@id":"https:\/\/www.couchbase.com\/de\/#website"},"datePublished":"2025-12-23T04:01:49+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-ruby-couchbase-orm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/"},{"@type":"ListItem","position":2,"name":"Quickstart in Couchbase with Ruby Couchbase ORM"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/de\/#website","url":"https:\/\/www.couchbase.com\/de\/","name":"Couchbase","description":"The Operational Data Platform for AI\u2122","publisher":{"@id":"https:\/\/www.couchbase.com\/de\/#organization"},"alternateName":"Couchbase, Inc.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/de\/#organization","name":"Couchbase","alternateName":"Couchbase, Inc.","url":"https:\/\/www.couchbase.com\/de\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.couchbase.com\/de\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","contentUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","width":1129,"height":1129,"caption":"Couchbase"},"image":{"@id":"https:\/\/www.couchbase.com\/de\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Couchbase\/","https:\/\/x.com\/couchbase","https:\/\/www.youtube.com\/c\/CouchbaseServer","https:\/\/www.linkedin.com\/company\/couchbase\/","https:\/\/github.com\/couchbase\/","https:\/\/en.wikipedia.org\/wiki\/Couchbase,_Inc."],"description":"Couchbase ist ein in San Jose, Kalifornien, ans\u00e4ssiges Unternehmen f\u00fcr Datenbanksoftware, das eine operative Datenplattform f\u00fcr KI bereitstellt, die von Hunderten von globalen Unternehmen eingesetzt wird.","legalName":"Couchbase, Inc.","foundingDate":"2011-01-01"}]}},"acf":[],"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorials\/10248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorials"}],"about":[{"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/types\/tutorials"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorials\/10248\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/media?parent=10248"}],"wp:term":[{"taxonomy":"tutorial-languages","embeddable":true,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorial-languages?post=10248"},{"taxonomy":"tutorial-tags","embeddable":true,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorial-tags?post=10248"},{"taxonomy":"tutorial-technologies","embeddable":true,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorial-technologies?post=10248"},{"taxonomy":"tutorial-types","embeddable":true,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorial-types?post=10248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}